trading_agent.backends.claude_steering_hook
¶
A PostToolUse hook that hands the user's mid-turn messages to Claude.
After every tool call, Claude Code asks this hook whether to add anything to what Claude reads next. When the desk's steering inbox holds messages, the hook returns them as additional context, so Claude sees them before its next step, exactly as the agent loop adds them for the local models.
Typical usage example:
hook = ClaudeSteeringHook(inbox) hooks = {'PostToolUse': [claude_agent_sdk.HookMatcher(hooks=[hook])]}
ClaudeSteeringHook
¶
Adds waiting user messages to Claude's context after each tool call.
Creates the hook.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inbox
|
SteeringInbox
|
The desk's steering inbox. |
required |
Source code in src/trading_agent/backends/claude_steering_hook.py
__call__
async
¶
Returns the waiting messages, if any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hook_input
|
dict[str, Any]
|
The hook's input from Claude Code, unused. |
required |
tool_use_id
|
str | None
|
The call's identifier, unused. |
required |
context
|
Any
|
The hook context, unused. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
An empty dict when nothing is waiting, or a PostToolUse output with the messages as additional context. |