Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 06:00 UTC
fix(py): accept blocked session execution results (#5292)
> Written by an AI agent on behalf of @olearycrew, following their spec. @olearycrew has not reviewed it yet. ## Summary Fixes [DEVREL-313](https://linear.app/composio/issue/DEVREL-313), the blocked-result mismatch observed in Gauge run `cmvtk2xiq000301fy68jp6nn8`. Python session execution already returns `result_type="blocked"` when a session hook blocks a call, but its SDK response model inherits `Optional[Literal["completed", "failed"]]`. Parsing that result again raises a Pydantic validation error. The [production API contract](https://backend.composio.dev/api/v3.1/openapi.json) includes `ExecuteBlocked` in the session execute response union. The pinned `composio-client==2.1.6` correctly represents it as a separate `SessionExecuteBlockedResponse` variant. The SDK combines those variants into `ToolRouterSessionExecuteResponse`, so that SDK-owned model needs the wider literal. TypeScript already includes `blocked` in `ToolRouterSessionExecuteResponseSchema` and handles the same normalization. ## Changes - Include `blocked` in the Python SDK response field, preserving its existing optional default. - Extend the existing blocked-response test to parse the normalized result again, covering both `session.execute` and custom-tool context execution. - Add a Python patch changeset. - Regenerate the Python tools reference to keep its source link aligned with the changed line numbers. ## Type of change - [x] Bug fix - [ ] New feature - [ ] Refactor/Chore - [ ] Documentation - [ ] Breaking change ## How Has This Been Tested? Python 3.14.7, `composio-client==2.1.0`: ```text Before: pytest tests/test_tool_router.py -k test_execute_returns_a_blocked_result -q 2 failed, 230 deselected ValidationError: result_type: Input should be 'completed' or 'failed' After: pytest tests/test_tool_router.py tests/test_custom_tools.py tests/test_tool_execution.py -q 383 passed in 2.79s ``` Ruff check with `python/config/ruff.toml` and Ruff format check passed for both changed Python files. Focused mypy with the repository config and `--follow-imports=silent` passed for both files. `git diff --check` passed. Mypy with imported modules checked reports four existing errors: missing `jsonschema` stubs and two incompatible argument annotations in `url_safety.py`. The same errors reproduce with the unchanged base model through mypy's `--shadow-file` option. After rebasing onto `next` at `3de004f26`, the same 383 tests passed again in 3.70s with `composio-client==2.1.6`. Ruff check and format check passed. Running `uv run --frozen --only-group docs-reference python scripts/generate-docs.py` twice produced the committed source-link update and then no further changes. No docs build or Gauge rerun was performed. ## Screenshots (if applicable) Not applicable. ## Checklist - [x] I have read the Code of Conduct and this PR adheres to it - [x] I have read and understand every line of this diff, including any LLM-generated code - [x] Any third-party docs links or promotional content follow the third-party links policy - [x] I ran linters/tests locally and they passed - [x] I updated documentation as needed - [x] I added tests or explain why not applicable - [x] I added a changeset if this change affects published packages ## Additional context The ticket's `composio.create` class inspection and `AnthropicProvider` import claims are agent introspection mistakes, as the ticket explains. They are unchanged. No generated client, TypeScript, provider, or docstring changes are needed. A blocked tool call already reaches Python callers. This change lets the declared response model accept that result when callers parse it again. The human author should review the full diff before merging. ### CI after the rebase The [SDK reference drift check](https://github.com/ComposioHQ/composio/actions/runs/42832465178/job/129885807832) now passes. The remaining docs failures are repo-wide: `dashboard-log-storage: review window expired` stops dependency installation before the checks or build run. The same error appears in the Vercel deployments for PRs #5302 and #5299. Affected checks: [Vercel](https://vercel.com/composio/docs/AkDTksf47kxeuxacwJzDEVTgEsCc), [check-links](https://github.com/ComposioHQ/composio/actions/runs/42832465627/job/129885808591), [test](https://github.com/ComposioHQ/composio/actions/runs/42832465501/job/129885809335), and [typescript-check](https://github.com/ComposioHQ/composio/actions/runs/42832464993/job/129885808421). These are outside this SDK fix and have been left unchanged.