agent improvement
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -177,6 +177,20 @@ class AgentRunner:
|
||||
def model(self, value: str):
|
||||
self._get_connection().set_model(value)
|
||||
|
||||
@property
|
||||
def permission_mode(self) -> str:
|
||||
conn = self._get_connection()
|
||||
return getattr(conn, "_permission_mode", "default")
|
||||
|
||||
@permission_mode.setter
|
||||
def permission_mode(self, value: str):
|
||||
conn = self._get_connection()
|
||||
if hasattr(conn, "_permission_mode"):
|
||||
conn._permission_mode = value
|
||||
import cht.config
|
||||
cht.config.AGENT_PERMISSION_MODE = value
|
||||
log.info("Permission mode set to %s", value)
|
||||
|
||||
def clear_history(self):
|
||||
self._thread = AgentThread()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user