- Session hooks that can block a tool call before it runs or block its result before the agent sees it
- The create() and update() methods accept a hooks option; on update(), hooks replaces the whole list and null removes every hook
- Blocked tool calls return resultType 'blocked' with empty data, the hook's message in error, and blockReason from session.execute() and session.executeMeta()
- Results include hookResults when a hook applied
- The hooks option cannot be combined with experimental.sessionConfigId
- session.proxyExecute() and ctx.proxyExecute() now return resultType 'completed' or 'blocked', so code reading status must check resultType first signature changed · inferred, marked in the notes below
1 change to check, marked in the notes below
From Composio
Minor Changes
-
c2bbfa8: Add session hooks. A hook can block a tool call before it runs, or block its result before the agent sees it.
create()andupdate()accepthooks. Onupdate(),hooksreplaces the whole list andnullremoves every hook.hookscannot be combined withexperimental.sessionConfigId.const session = await composio.create('user_123', { hooks: [ { type: 'before_execute', id: 'no_external_email', name: 'No external email', appliesTo: { toolkits: ['gmail'] }, handler: { type: 'condition_check', condition: 'Sending email to anyone outside example.org', action: 'block', }, }, ], });A blocked call comes back from
session.execute()andsession.executeMeta()withresultType: 'blocked', emptydata, the hook's message inerror, andblockReason. Provider integrations hand it to the agent as a failed call with that message. Every result also carrieshookResultswhen a hook applied.session.proxyExecute()andctx.proxyExecute()now returnresultType: 'completed'orresultType: 'blocked'. A blocked request has no HTTP response, so TypeScript code that readsstatushas to checkresultTypefirst. signature changed · inferred