hooks
code_context_agent.agent.hooks ¶
Hook providers for agent guidance and quality control.
This module provides HookProvider implementations that integrate with the Strands hook system for contextual guidance during agent execution.
Uses stable strands.agent.hooks API (not experimental steering).
FullModeToolError ¶
Bases: RuntimeError
Raised by FailFastHook when a critical tool returns an error in full mode.
Source code in src/code_context_agent/agent/hooks.py
OutputQualityHook ¶
Bases: HookProvider
Hook for output quality enforcement.
Checks tool results for size limit violations and logs warnings when outputs are unusually large.
register_hooks ¶
ToolEfficiencyHook ¶
Bases: HookProvider
Hook for tool usage optimization.
Warns when shell is used for tasks that have dedicated tools.
register_hooks ¶
FailFastHook ¶
Bases: HookProvider
Hook that raises on tool errors in --full mode.
In full mode, most tool failures should halt analysis immediately rather than silently degrading. Exempt tools (search, shutdown, MCP) are allowed to fail without halting.
register_hooks ¶
create_all_hooks ¶
Create all hook providers for agent guidance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
full_mode | bool | If True, include FailFastHook for strict error handling. | False |
Returns:
| Type | Description |
|---|---|
list[HookProvider] | List of HookProvider instances. |