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, 11:00 UTC
fix(sdk): stop sending expected_config_version by default on session update (#4603)
This PR: - makes `session.update()` work again with default options in both SDKs. Since `@composio/core` 0.20.0 and the matching Python release, every call sent the session's last observed version as `expected_config_version`, and the live API rejects it with a 400 (`Error in payload: Unrecognized key(s) in object: 'expected_config_version'`) - makes the precondition opt-in: pass `expectedConfigVersion` / `expected_config_version` (for example the session's `configVersion`) to make an update conditional; omitting it, or passing `false`, sends no precondition (last writer wins) - keeps the 409 handling, the no-retry rule and the conflict messages unchanged for callers who opt in - adds live regression tests that send a default `session.update()` to the real API: a Node e2e suite (`ts/e2e-tests/runtimes/node/tool-router-session-update`) and a Python integration test (`python/composio/integration_test/test_tool_router_session_update.py`). Mocked unit tests could not catch this bug because they never reach the API's payload validation - updates the "Concurrent updates" docs, JSDoc/docstrings and the generated references; adds a patch changeset for `@composio/core` ## Testing - `pnpm --filter @composio/core test` (1512 passed) and `pnpm --filter @composio/core typecheck` - `pytest tests/test_tool_router.py` (127 passed); ruff with `config/ruff.toml` is clean; mypy reports nothing in the touched files - Tests now assert that the default sends no precondition; the conflict and two-handle tests pass the version explicitly - Regression tests: both fail on `next` with the 400 above and pass with this fix; the Node suite also passes in the Docker e2e harness (6/6) - Live, against a real project: default `update()` succeeds in TypeScript (version 1 -> 2) and Python; an explicit `expectedConfigVersion` still gets the 400 above until the API supports the field Out of scope, found during the same live run: the API also rejects `toolkits: null` on update (`Error in payload.toolkits: Invalid …`), which the SDK documents as "remove the stored policy". ## Why this shipped #4579 made the precondition the default while the backend support (ComposioHQ/platform#13157) and the client regeneration (ComposioHQ/composio-client#59) were still open. The pinned client does not type the field, so the SDK sent it through a widened body cast (TS) and `extra_body` (Python), and only mocked tests covered it. CI e2e runs against staging (`COMPOSIO_BASE_URL_STAGING`), so a production-only mismatch still needs a nightly run against production; that is not part of this PR.