Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
fix(py): expose premium charge on session execute responses (#4623)
## Summary This PR: - follows up on https://github.com/ComposioHQ/composio/pull/4599, which added the `premium_usage.return_premium_charge` opt-in to both SDKs but only surfaced the resulting `premium_charge` on TypeScript responses - types `session.execute()` results as `ToolRouterSessionExecuteResponse` (matching the TypeScript name, exported from `composio.core.models`), a subclass of the generated client's `SessionExecuteResponse` with `premium_charge: Optional[PremiumCharge]`, so it's no longer an untyped pydantic extra - adds `premium_charge` as a `NotRequired` key on `ToolExecutionResponse`, and has the provider-wrapped session execute function forward it; previously it rebuilt the result as `{data, error, successful}` and dropped the charge for every framework integration - keeps the remote charge when `COMPOSIO_MULTI_EXECUTE_TOOL` mixes local custom tools with remote tools, matching the TypeScript merge in `ToolRouterSession.ts` - exports the new `PremiumCharge` TypedDict (`amount`, `currency`, `charged_by`, per the OpenAPI execute response) from `composio.types` `composio-client` 2.0.0rc8 is still the latest release and doesn't declare `premium_charge`, so the typing lives in the SDK. `session.execute()` rebuilds the response with `model_construct` so a malformed charge can't raise after the tool has already run. Existing `isinstance` checks against the client's `SessionExecuteResponse` still pass. ## Type of change - [x] Bug fix - [ ] New feature - [ ] Refactor/Chore - [ ] Documentation - [ ] Breaking change ## How Has This Been Tested? - `nox -s chk` (ruff + mypy): passes - `nox -s tst`: 2082 passed, 41 skipped - New regression tests cover `session.execute()` with and without a charge, the provider wrapper with and without a charge, and a mixed local/remote multi-execute ## Checklist - [ ] I have read the Code of Conduct and this PR adheres to it - [ ] 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](https://github.com/ComposioHQ/composio/blob/next/CONTRIBUTING.md#third-party-links-in-docs) - [x] I ran linters/tests locally and they passed - [ ] I updated documentation as needed - [x] I added tests or explain why not applicable - [ ] I added a changeset if this change affects published packages ## Additional context No changeset: this only touches the Python SDK, which doesn't use Changesets. TypeScript still types `premiumCharge` as `unknown`. Narrowing it to the same shape would be a separate follow-up.