@devries-cameron20 / composio Mirror · read-only / commits / f744fdf69
Fork 0

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, 08:30 UTC

fix(core): match the hooks contract on staging

Unavailable hook results no longer carry a reason, and a hook that cannot be evaluated no longer blocks the call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Mukund committed Oct 20, 2026 at 10:19 UTC f744fdf690a5f11a6347de61bdb0b5509cee6b92
4 files changed +36 -8
python/composio/core/models/custom_tool_types.py
+2 -2
@@ -43,11 +43,11 @@ class ToolRouterHookEvaluatedResult(te.TypedDict):
43
44
45 class ToolRouterHookUnavailableResult(te.TypedDict):
46 - """A session hook that could not be evaluated. The call is blocked."""
46 + """A session hook that could not be evaluated, for example because it
47 + timed out. It does not block the call."""
48
49 id: str
50 status: t.Literal["unavailable"]
50 - reason: t.Literal["timeout", "error"]
51
52
53 ToolRouterHookResult = t.Union[
python/tests/test_tool_router.py
+18
@@ -2922,6 +2922,24 @@ class TestSessionHooks:
2922 assert result["data"] == {}
2923 assert result["error"] == "Blocked by session policy: No external email"
2924
2925 + def test_unavailable_hook_does_not_block(self):
2926 + """A hook that could not be evaluated is reported, and the call still
2927 + returns its normal result."""
2928 + client, _ = _answering_client(
2929 + {
2930 + **_COMPLETED_JSON,
2931 + "hook_results": [{"id": "block_injection", "status": "unavailable"}],
2932 + }
2933 + )
2934 +
2935 + result = _created_session(client).execute("GMAIL_SEND_EMAIL", arguments={})
2936 +
2937 + assert result.result_type == "completed"
2938 + assert result.data == {"id": "msg_1"}
2939 + assert result.hook_results == [
2940 + {"id": "block_injection", "status": "unavailable"}
2941 + ]
2942 +
2943 def test_malformed_blocked_response_is_raised(self):
2944 malformed = {k: v for k, v in _BLOCKED_CALL_JSON.items() if k != "reason"}
2945 client, _ = _answering_client(malformed)
ts/packages/core/src/types/toolRouter.types.ts
+5 -2
@@ -824,7 +824,11 @@ export type ToolRouterSessionSearchResponse = z.infer<typeof ToolRouterSessionSe
824
825 // --- Session hook results (camelCase) ---
826
827 -/** What one session hook decided about a call. */
827 +/**
828 + * What one session hook decided about a call. `unavailable` means the hook
829 + * could not be evaluated (for example it timed out); it does not block the
830 + * call.
831 + */
832 export const ToolRouterHookResultSchema = z.discriminatedUnion('status', [
833 z.object({
834 id: z.string().describe('The hook id'),
@@ -834,7 +838,6 @@ export const ToolRouterHookResultSchema = z.discriminatedUnion('status', [
838 z.object({
839 id: z.string().describe('The hook id'),
840 status: z.literal('unavailable'),
837 - reason: z.enum(['timeout', 'error']).describe('Why the hook could not be evaluated'),
841 }),
842 ]);
843 export type ToolRouterHookResult = z.infer<typeof ToolRouterHookResultSchema>;
ts/packages/core/test/models/sessionHooksExecution.test.ts
+11 -4
@@ -31,7 +31,7 @@ const blockedResponse = {
31 message: 'Blocked by session policy',
32 log_id: 'log_456',
33 instant_charge: { amount: '0.01', currency: 'USD', charged_by: 'composio' },
34 - hook_results: [{ id: 'no_outside_data', status: 'unavailable', reason: 'timeout' }],
34 + hook_results: [{ id: 'no_outside_data', status: 'evaluated', outcome: 'block' }],
35 };
36
37 const { log_id: _logId, ...blockedProxy } = blockedCall;
@@ -101,7 +101,7 @@ describe('session execute when a hook blocks the call', () => {
101 logId: 'log_456',
102 resultType: 'blocked',
103 blockReason: { type: 'response_blocked', hookId: 'no_outside_data' },
104 - hookResults: [{ id: 'no_outside_data', status: 'unavailable', reason: 'timeout' }],
104 + hookResults: [{ id: 'no_outside_data', status: 'evaluated', outcome: 'block' }],
105 instantCharge: { amount: '0.01', currency: 'USD', charged_by: 'composio' },
106 });
107 });
@@ -130,15 +130,22 @@ describe('session execute when a hook blocks the call', () => {
130 data: { id: 'msg_1' },
131 error: null,
132 log_id: 'log_1',
133 - hook_results: [{ id: 'no_external_email', status: 'evaluated', outcome: 'continue' }],
133 + hook_results: [
134 + { id: 'no_external_email', status: 'evaluated', outcome: 'continue' },
135 + { id: 'block_injection', status: 'unavailable' },
136 + ],
137 });
138
139 + // A hook that could not be evaluated does not block: the call still ran.
140 await expect(createSession(client).execute('GMAIL_SEND_EMAIL', {})).resolves.toEqual({
141 data: { id: 'msg_1' },
142 error: null,
143 logId: 'log_1',
144 resultType: 'completed',
141 - hookResults: [{ id: 'no_external_email', status: 'evaluated', outcome: 'continue' }],
145 + hookResults: [
146 + { id: 'no_external_email', status: 'evaluated', outcome: 'continue' },
147 + { id: 'block_injection', status: 'unavailable' },
148 + ],
149 });
150 });
151