Block a read of file lines already in the agent's context, unless a compaction dropped them or the file changed
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import dataclasses
|
||||
import posixpath
|
||||
import typing
|
||||
|
||||
from failure import Failure
|
||||
@@ -13,6 +14,8 @@ class Call:
|
||||
cwd: str
|
||||
# The subagent the call comes from, such as prose-reviewer; empty for the session's own agent.
|
||||
agent: str = ""
|
||||
# The transcript of the agent that makes the call: a subagent's own, not its session's.
|
||||
transcript: str = ""
|
||||
|
||||
|
||||
def parsed_call(hook_input: object) -> Call | Failure:
|
||||
@@ -21,8 +24,12 @@ def parsed_call(hook_input: object) -> Call | Failure:
|
||||
tool, given, cwd = hook_input.get("tool_name"), hook_input.get("tool_input"), hook_input.get("cwd")
|
||||
if not isinstance(tool, str) or not isinstance(given, dict) or not isinstance(cwd, str):
|
||||
return Failure("the hook input has no string tool_name and cwd and object tool_input")
|
||||
agent = hook_input.get("agent_type")
|
||||
return Call(tool, given, cwd, agent if isinstance(agent, str) else "")
|
||||
agent, agent_id, transcript = hook_input.get("agent_type"), hook_input.get("agent_id"), hook_input.get("transcript_path")
|
||||
transcript = transcript if isinstance(transcript, str) else ""
|
||||
if isinstance(agent_id, str) and transcript:
|
||||
# Inside a subagent, transcript_path still names the session's transcript; the subagent's own sits beside it.
|
||||
transcript = posixpath.join(posixpath.splitext(transcript)[0], "subagents", f"agent-{agent_id}.jsonl")
|
||||
return Call(tool, given, cwd, agent if isinstance(agent, str) else "", transcript)
|
||||
|
||||
|
||||
def text(given: dict[str, typing.Any], key: str) -> str:
|
||||
|
||||
Reference in New Issue
Block a user