Actions
agent_gate.actions
¶
Normalize a PreToolUse hook payload into an :class:Action.
The agent's own account of a call is removed here. A Bash call carries a
description the agent wrote about the command; the gate judges the
command, never the description.
Action(tool, params, cwd, session_id, tool_use_id)
dataclass
¶
One tool call, as the gate judges it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool
|
str
|
the tool name, e.g. |
required |
params
|
dict[str, Any]
|
the tool input with narrative fields removed. |
required |
cwd
|
Path
|
the agent's working directory. |
required |
session_id
|
str
|
the Claude Code session. |
required |
tool_use_id
|
str
|
the id of this call. |
required |
command
property
¶
The shell command of a Bash call, else an empty string.
consequential
property
¶
True unless the call only reads.
is_mcp
property
¶
True for an MCP tool.
mcp_read_only
property
¶
True for an MCP tool whose name starts with a read verb.
from_hook(payload)
classmethod
¶
Build an action from a PreToolUse hook payload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
dict[str, Any]
|
the JSON object Claude Code writes to the hook's stdin. |
required |
Source code in src/agent_gate/actions.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
params_text(limit=2000)
¶
The tool input as stable JSON, capped, used to spot retries of a blocked action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit
|
int | None
|
the maximum length kept, or |
2000
|
Source code in src/agent_gate/actions.py
121 122 123 124 125 126 | |