agent improvement

This commit is contained in:
2026-04-09 14:58:15 -03:00
parent 64ecdca71e
commit e69fec5aea
5 changed files with 141 additions and 56 deletions

View File

@@ -37,9 +37,11 @@ You help the user understand what happened during their recording session.
You have access to frame screenshots extracted from the recording. When frames are mentioned,
use the Read tool to view them. Frame timestamps are in seconds from the start of the recording.
You also have tools to search transcripts, get session info, and capture new frames.
You can use any available tools including WebFetch and WebSearch when the user asks you to
look something up. Use them freely — all tools are pre-authorized.
Be concise and specific. Focus on what's visible in the frames."""
Your primary role is description and analysis, not code generation. Be concise and specific.
Focus on what's visible in the frames and what's in the transcript."""
MODELS = [
"claude-sonnet-4-6",
@@ -78,21 +80,16 @@ def _messages_to_prompt(messages: list[Message]) -> str:
return "\n".join(lines)
def _tool_schemas(tools: list[Tool]) -> list[str]:
"""Extract tool names for the SDK's allowed_tools parameter."""
# The Claude SDK uses allowed_tools as a list of tool name strings.
# Our custom tools are executed by the runner, not by the SDK,
# so we only pass "Read" to the SDK (for frame viewing).
return ["Read"]
class ClaudeSDKConnection:
"""AgentConnection using claude_agent_sdk — requires Claude Code CLI."""
def __init__(self, cwd: str | None = None, max_turns: int = 5, model: str = MODELS[0]):
def __init__(self, cwd: str | None = None, max_turns: int | None = None,
model: str = MODELS[0], permission_mode: str | None = None):
from cht.config import AGENT_PERMISSION_MODE, AGENT_MAX_TURNS
self._cwd = cwd
self._max_turns = max_turns
self._max_turns = max_turns or AGENT_MAX_TURNS
self._model = model
self._permission_mode = permission_mode or AGENT_PERMISSION_MODE
self._cancelled = False
@property
@@ -147,9 +144,9 @@ class ClaudeSDKConnection:
options=ClaudeAgentOptions(
model=self._model,
cwd=cwd or ".",
allowed_tools=_tool_schemas(tools),
system_prompt=SYSTEM_PROMPT,
max_turns=self._max_turns,
permission_mode=self._permission_mode,
),
):
if self._cancelled: