chore: remove mypy from CI and dev dependencies
mypy hasn't caught issues in a long time due to its lenient config
(follow_imports=skip, ignore_missing_imports=true). We evaluated ty as
a replacement but it lacks Pydantic and SQLModel support, producing too
many false positives. Removing the type checker until a viable
alternative matures.
* fix: redact sensitive information from log output
Mask or remove API keys, passwords, tokens, auth settings, and
configuration values from logger calls and print statements to prevent
clear-text exposure of credentials in logs.
* fix: address code review feedback on sensitive info redaction
- Restore full API key display in Windows fallback banner (masking
defeated the purpose of showing the key for the only time)
- Revert test helper masking in locust setup (developers need full
credentials for load testing)
- Add missing await on logger.adebug in agentic_mcp
- Remove redundant duplicate log line in openai_responses
* fix: replace unnecessary dict comprehension with dict() call
---------
Co-authored-by: Janardan Singh Kavia <janardankavia@ibm.com>
* feat: add token usage tracking for LLM and Agent components
Track input/output/total tokens across LLM providers (OpenAI, Anthropic,
Ollama) and display them on both node badges and chat messages.
Backend: thread-safe callback handler for agent token accumulation,
usage_metadata extraction for Ollama/LangChain standard, pipeline
integration from component through vertex to API response.
Frontend: token count formatting utility, Coins icon badge on nodes
with tooltip breakdown, chat message status with token display.
* feat: accumulate token usage across serial LLMs on chat messages
Add upstream token usage accumulation so chat messages display the
total tokens from all LLMs in the pipeline, not just the last one.
Output vertex node badges hide token counts since the accumulated
total is shown on the chat message instead.
* chore: add CLAUDE.local.md to .gitignore
* chore: update starter project templates for token usage tracking
* fix: enable token usage tracking for streaming LLM responses
Enable stream_usage=True on OpenAI and Anthropic model constructors so
the API includes token counts in streaming chunks.
Fix _handle_stream to propagate the AIMessage back to _get_chat_result
when not connected to a chat output, so usage can be extracted from the
invoke fallback path.
Accumulate usage across multiple streaming chunks instead of overwriting,
since Anthropic splits input/output tokens across separate events.
* [autofix.ci] apply automated fixes
* [autofix.ci] apply automated fixes (attempt 2/3)
* refactor: centralize token usage extraction into shared module
Extract duplicated token usage logic from Component, LCModelComponent,
TokenUsageCallbackHandler, and Vertex into a shared lfx.schema.token_usage
module. Replace loose dict typing with the existing Usage Pydantic model
throughout the token tracking pipeline. Declare _token_usage on Component
__init__ instead of dynamically injecting it.
* [autofix.ci] apply automated fixes
* [autofix.ci] apply automated fixes (attempt 2/3)
* [autofix.ci] apply automated fixes
* feat: add validation for token_usage field in ResultDataResponse
* feat: enable stream_usage in OpenAI model tests
* [autofix.ci] apply automated fixes
* [autofix.ci] apply automated fixes
* refactor: consolidate token usage extraction into single source of truth
Eliminate ~75 lines of duplicated LLMResult token extraction logic between
the token usage feature (TokenUsageCallbackHandler) and the traces feature
(NativeCallbackHandler) by adding a shared extract_usage_from_llm_result()
function. Also fix missing usage property mapping in chat history hook so
token counts display correctly in playground messages.
* feat: add token usage tracking to all LLM components
Add token usage extraction to the 7 remaining components that make LLM
calls but weren't tracking token consumption:
- Smart Router: direct extract_usage_from_message after invoke
- Guardrails: accumulate_usage across multiple guardrail checks
- Batch Run: accumulate_usage across batch responses
- Smart Transform: extract after ainvoke (already done in prior commit)
- Structured Output: via token_usage_callback on get_chat_result
- LLM Selector: direct extract for judge + callback for selected model
- NotDiamond: via token_usage_callback on get_chat_result
Also adds a backward-compatible token_usage_callback parameter to
get_chat_result() so components using that shared helper can capture
the AIMessage before it's reduced to .content.
* [autofix.ci] apply automated fixes
* fix: update mock_get_chat_result signatures to accept token_usage_callback
The structured output test mocks define explicit parameter lists for
get_chat_result but were missing the new token_usage_callback kwarg,
causing CI failure. Add **kwargs to all mock definitions.
* fix: address PR review findings for token usage UI and data flow
- Remove bare "bg" Tailwind class and replace hard-coded bg-neutral-700
with semantic bg-success-background on success tooltip (C2/C3)
- Propagate usage properties regardless of source.id presence so agent
inner messages still show token counts (H9)
- Make PropertiesType.source optional to match the new data flow
- Restore "in" preposition in "Finished in X.Xs" chat message (M10)
- Fix misleading "optional dependency" comment in native_callback.py (C1)
* fix: structured output token usage not captured due to config key mismatch
get_chat_result() reads "get_langchain_callbacks" as a callable, but
structured output was passing "callbacks" as a list — the token handler
was silently dropped. Fix by matching the expected key names and
injecting TokenUsageCallbackHandler via the LangChain callback chain
instead of the token_usage_callback parameter (which doesn't fire for
structured output chains that return Pydantic models, not AIMessages).
* [autofix.ci] apply automated fixes
* [autofix.ci] apply automated fixes (attempt 2/3)
* chore: update component index
* test: add E2E tests for token usage tracking
* [autofix.ci] apply automated fixes
* test: add missing unit tests from PR review
Adds the 4 recommended test scenarios identified in Cristhianzl's review
of PR #11891 (token usage tracking):
- TestStreamingTokenAccumulation: verifies extract_usage_from_chunk() +
accumulate_usage() correctly accumulates across multiple streaming chunks
(OpenAI, Anthropic, and usage_metadata formats)
- TestChatOutputTokenUsageAccumulation: verifies message_response() sets
upstream token usage on the message and updates the stored message when
applicable
- TestAgentTokenCallbackWiring: verifies TokenUsageCallbackHandler is wired
into run_agent() callbacks and its result is stored on _token_usage
- TestResultDataResponseTokenUsageValidator: verifies the field_validator
converts Usage Pydantic models to dicts and passes through None/dict values
* [autofix.ci] apply automated fixes
* Revert "[autofix.ci] apply automated fixes"
This reverts commit c618b12498.
* [autofix.ci] apply automated fixes
* [autofix.ci] apply automated fixes
* fix: move hover action bar above message to prevent overlap with header row
Position the EditMessageButton toolbar using \`bottom-full\` instead of \`-top-4\` so it always sits fully above the message container. This prevents the button bar from overlapping the 'Finished in' usage/time row in bot messages.
* [autofix.ci] apply automated fixes
* feat: add token usage tooltip to bot message and fix node status background
- Wrap "Finished in" stat in a ShadTooltip showing last run time, duration, input/output token breakdown
- Fix node status success background color from bg-success-background to bg-zinc-700
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* feat: add list (llms) endpoint and wxo implemetation
* use provider_data/provider_result fields instead of top-level llms field
* feat(wxo): make LLM user-configurable and add attach_tool operation
Replace hardcoded DEFAULT_WXO_AGENT_LLM with a required user-supplied
`llm` field on both API and adapter create/update payloads, threaded
through mapper → service → plan → agent call. LLM-only updates (no
tool operations) are now supported.
Add `attach_tool` adapter operation to attach an existing provider tool
to a deployment without connection bindings. At the API layer, bind
operations now accept empty `app_ids` to create/attach a flow version
as an unbound raw tool; the mapper translates this by emitting the raw
tool payload while skipping the provider bind operation, preserving the
adapter-layer invariant that bind always requires non-empty app_ids.
Pre-seed raw_tool_app_ids from declared raw payloads so unbound tools
are created even without a referencing bind operation. Add overlap
validation for conflicting operations on the same tool_id (attach+bind,
remove+bind/unbind, bind/unbind app_id overlap, duplicate attach/remove).
* fix(wxo): improve LLM listing and update code review feedback
Add dedicated LIST_LLMS error prefix so LLM-listing failures are
distinguishable from deployment-list errors in user-facing messages.
Fix test URL path in _with_wxo_wrappers to match the real
WxOClient.get_models_raw endpoint (/models, not /v1/models).
Clarify API contract and intent via docstrings: document that
operations defaults to empty for LLM-only updates, that
build_update_payload_from_spec treats None as "not provided",
and that duplicate models are intentionally passed through.
* fix(wxo): make snapshot update contracts explicit and strict
Split update snapshot semantics into created/added/removed/referenced bindings, remove fallback masking, and enforce strict reconciliation for added flow-version bindings.
Also fix rollback update handling to avoid MissingGreenlet by passing scalar deployment identifiers after rollback, with updated tests across mapper, sync, route, and service coverage.
* harden resource_name_prefix presence validation for update path
* improve ux for missing field error messages
* fix: restore exclude_unset semantics, consolidate has_tool_work, fix format_first_error for model validators
- Restore model_dump(exclude_unset=True) in build_update_payload_from_spec
so explicitly-set None fields (e.g. description=null) are distinguishable
from omitted fields.
- Add has_tool_work property on WatsonxDeploymentUpdatePayload and use it
in the service layer instead of duplicating the routing logic inline.
- Fix format_first_error() to pass through model-validator value_error
messages instead of sanitizing them to generic "Invalid payload."
- Add missing llm field to pre-existing update schema tests.
* Add explicit is not none check to spec update name
* [autofix.ci] apply automated fixes
---------
Co-authored-by: Jordan Frazier <jordan.frazier@datastax.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* feat: (wxo) list(agents/conns/tools) and update(agents) directly from langflow api
* improve error handling, schema constraints, and clean up logic
* rollback on create from existing
* feat(deployments): add include_provider param to DELETE, cascade-delete tools/configs
Adds `include_provider` query param (default true) to DELETE /{deployment_id}.
When true, cascade-deletes the agent's bound tools and connections on the
provider (best-effort) before removing the agent and local DB row.
When false, only the local DB row is removed.
Also fixes 5 pre-existing test failures where mapper mocks were missing
util_existing_deployment_resource_key_for_create.return_value = None.
* [autofix.ci] apply automated fixes
* Remove cascading delete
only support deletion of agents, not tools or connections,
for this iteration.
* [autofix.ci] apply automated fixes
* fix ruff checks
* set default true properly
* fix mapper tests
---------
Co-authored-by: Jordan Frazier <jordan.frazier@datastax.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jordan Frazier <122494242+jordanrfrazier@users.noreply.github.com>
fix(deps): pin tar-fs to >=2.1.4 to fix symlink following vulnerability (#12078)
Adds override for tar-fs in package.json to ensure versions prior to
2.1.4 are never resolved. Addresses CVE in tar-fs <2.1.4 (PVR0686558)
where symlink validation bypass was possible with a crafted tarball.
Co-authored-by: Ram Gopal Srikar Katakam <44802869+RamGopalSrikar@users.noreply.github.com>
* feat: add pure flow-builder utilities to lfx
Add flow_builder subpackage with pure functions for manipulating
flow JSON dicts — component ops, edge creation with ReactFlow
handle format, topological layout, and dynamic field detection.
* feat: add MCP server for operating Langflow via REST API
FastMCP server exposing 15 tools across auth, flow, component,
connection, and execution groups. Agents can create flows, add
and configure components, wire connections, and run flows against
a Langflow server through MCP tool calls.
* feat: add langflow-mcp-client console script entry point
* fix: use dict comprehension in setup.py to fix PERF403 lint
* fix: address PR review feedback on MCP client
- Add asyncio.Lock to prevent race condition in _client() under
concurrent access
- Handle 204 No Content responses in delete() instead of calling
resp.json() on empty body
- Fix weak assertion in test_default_values
* feat: auto-enable tool_mode when connecting component_as_tool
describe_component_type now shows component_as_tool as an output
for any component with tool_mode-capable outputs. When an agent
connects via component_as_tool, tool_mode is auto-enabled — no
extra step needed.
* refactor: move MCP server from langflow-base to lfx
The MCP server has no langflow dependencies — only httpx, mcp,
and lfx.graph.flow_builder. Moving it to lfx.mcp makes it usable
without installing langflow. Entry point: lfx-mcp.
* fix: isolate session state and harden MCP server
* fix: move test_flow_builder into tests/unit so CI collects coverage
* fix: add trailing slash to /api_key endpoint in MCP client login
The FastAPI endpoint redirects /api_key to /api_key/ (307) and httpx
drops the POST body on redirect, causing API key creation to fail
silently during login.
* fix: isolate session state and harden MCP server
contextvars alone lose state between stdio tool calls. Add module-level
fallback so login credentials persist across calls while still
supporting per-session isolation for SSE transport.
* fix: update test fixture to use contextvars-based server API
The mcp_client fixture was accessing mcp_server_module._client and
._registry directly, but these were replaced with contextvars
(_client_var, _shared_client, _set_client, etc.) in the server
module refactor.
* [autofix.ci] apply automated fixes
* fix: add connection type validation and fix session isolation
- add_connection() now enforces type compatibility using the Graph's
types_compatible() when types are resolved from the flow. Explicit
types bypass validation (caller takes responsibility).
- Session state uses only contextvars, removing _shared_client and
_shared_registry globals that leaked between SSE sessions.
- login() wraps old client close in contextlib.suppress so a failed
close doesn't prevent establishing a new session.
---------
Co-authored-by: Eric Hare <ericrhare@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Use urlparse for proper hostname validation instead of substring check (LE-719).
Replace Math.random() with crypto.randomUUID() in test fixtures (LE-718).
Co-authored-by: Janardan Singh Kavia <janardankavia@ibm.com>
* fix(docs): update fast-xml-parser to 4.5.4 to address security vulnerability
- Add override for fast-xml-parser to force version 4.5.4
- Fixes entity encoding bypass via regex injection in DOCTYPE entity names
- Addresses CVE in transitive dependency from redocusaurus
* ci: update merge-frontend-coverage if
update merge-frontend-coverage if to not run during doc changes
---------
Co-authored-by: Janardan S Kavia <janardanskavia@Janardans-MacBook-Pro.local>
Co-authored-by: Adam Aghili <Adam.Aghili@ibm.com>
* feat: add official wxo adk to langflow-base complete
* remove stale comment
* remove from complete installation. wait for feature flag to be dropped
* add extra to complete installation
* add core package as explicit dependency because it is used directly
* add temporary fix for adk regression
* fix: harden verify_credentials error handling and add dev IAM URL overrides
Move authenticator construction inside try/except to catch SDK validation
errors directly from the constructor instead of calling validate() twice.
Add env var overrides (IBM_IAM_MCSP_DEV_URL_OVERRIDE, IBM_IAM_DEV_URL_OVERRIDE)
for non-production wxO environments that use different IAM endpoints.
Expand test coverage for constructor failures, 403 responses, and
empty/whitespace env var fallback behavior.
* improve docs
* tighten up docs
* fix typo
* [autofix.ci] apply automated fixes
* [autofix.ci] apply automated fixes (attempt 2/3)
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* ci: upgrade runtime to python:3.14.3-slim-trixie
upgrade our dockerfiles to use LTS runner version python:3.14.3-slim-trixie
* chore: stay with version 3.12
3.12
Wrap cloudModeStore localStorage access in try-catch to prevent crashes
in private browsing or SSR. Extract storage key to a constant. Log
errors in model refresh catch block instead of silently swallowing.
Remove unused filterEdge from useAddComponent deps. Type
CLOUD_INCOMPATIBLE_PROVIDERS as ReadonlySet.
* fix: enforce ownership check in build_flow endpoint (GHSA-qj98-rhf8-v93f)
POST /api/v1/build/{flow_id}/flow fetched flows by UUID without verifying
ownership, allowing any authenticated user to execute another user's private
flow and read its full build output.
- Replace session.get(Flow) with a scoped query that filters by
Flow.user_id == current_user.id OR access_type == PUBLIC
- Return 404 for both not-found and not-owned cases to avoid UUID enumeration
- Add _job_owners registry to JobQueueService (register_job_owner /
get_job_owner / cleanup on teardown)
- Register the job owner in build_flow after start_flow_build returns
- Harden GET /api/v1/build/{job_id}/events with the same ownership check;
jobs started via build_public_tmp have no registered owner and remain
accessible to any authenticated user
* style: fix ruff import order violations in chat.py and job_queue service
* test: add ownership security tests for build_flow (GHSA-qj98-rhf8-v93f)
Cover the attack scenarios fixed by the ownership check:
- Cross-user build blocked (attacker cannot build victim's private flow)
- Cross-user event polling blocked (attacker cannot read another user's job)
- Public flow remains accessible by any authenticated user
- Unauthenticated request is rejected
- Non-existent flow UUID returns 404
* fix: extend ownership check to cancel_build and add security event logging
- Add ownership check to cancel_build (prevents DoS via job cancellation
by a different authenticated user)
- Add logger.awarning on IDOR rejection in build_flow, get_build_events,
and cancel_build so that probing attempts are visible in production logs
- Add cross-reference comment in build_flow explaining why the query
intentionally extends _read_flow to include PUBLIC flows
* test: add cross-user cancel_build ownership test
Cover the DoS-via-job-cancellation attack vector: an attacker who knows a
job_id must receive 404 when attempting to cancel a build they do not own.
* fix: replace false-positive IDOR warning with accurate log message in build_flow
The previous warning fired for both legitimate 404s (non-existent flows) and
actual IDOR attempts (flow owned by another user), causing alert fatigue and
making real IDOR probing indistinguishable from client typos in production logs.
* [autofix.ci] apply automated fixes
* fix: address review recommendations for IDOR ownership check PR
- Extract _verify_job_ownership helper to centralize ownership check logic
- Add tests for build_public_tmp jobs accessible by any authenticated user
- Add test verifying _job_owners cleanup after cleanup_job
- Add @pytest.mark.security to all security regression tests
- Register security marker in pyproject.toml
* fix: apply ruff lint fixes to test_chat_endpoint
- Replace try-except-pass with contextlib.suppress
- Add missing contextlib import
- Add pragma: allowlist secret to suppress false-positive secret detection on test passwords
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
The grep -oP (PCRE regex) command fails in the python:3.12.12-slim-trixie
Docker base image because PCRE support is not available in the slim variant.
This replaces grep -oP with portable sed -nE in all 5 Dockerfiles and adds
an empty version guard to fail fast with a clear error message instead of
producing a broken download URL.
* Add feature flag around BE wxo deployments
* remove old comment
* [autofix.ci] apply automated fixes
* [autofix.ci] apply automated fixes (attempt 2/3)
* fix: improve consistency in feature flag logging and api
- Use consistent DEBUG log level for disabled-flag path in both
register_builtin_adapters and register_builtin_deployment_mappers
- Remove dead __getattr__ lazy-load hook and deployment_router from
__all__ in api/v1/__init__.py (no internal callers remain)
- Change _ensure_deployments_enabled_for_filters from 404 to 400 with
descriptive error message naming the wxo_deployments feature flag
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Hamza Rashid <hzarashid@gmail.com>
Add missing filterType to useAddComponent's useCallback deps so the
callback always sees the current output filter when adding a component.
Reset hasProcessedEmptyRef when flatOptions changes so model auto-select
fires again after cloud mode toggle changes the available options.
Mark git, google, and homeassistant components as cloud_compatible=False
since they require local filesystem, credentials files, or local network
access. Consolidate duplicated cloud metadata helpers into cloudMetadataUtils
and fix the nodeType resolution to use the explicit prop instead of falling
back to nodeClass.type. Fix model input empty state to distinguish disabled
models from cloud-filtered models.
Older flows saved before cloud metadata existed could miss cloud warnings
and option filtering. Overlay only the safe cloud fields from the
current catalog when Cloud Mode is on so existing node state stays
unchanged.
Keep preserved cloud-incompatible selections visible with inline warnings
and make model empty states follow the filtered cloud-compatible set.
Add a cloud default override for SearXNG and update the built component
index so non-dev startup matches cloud mode behavior.