Skip to content

Commit 4cbfd62

Browse files
committed
Improve agent tool call logging and switch to local sandbox
Add parameter summaries to debug logs for agent tool calls in both session managers. Switch default config from Docker to local sandbox.
1 parent 28da7d8 commit 4cbfd62

3 files changed

Lines changed: 36 additions & 4 deletions

File tree

predicators/agent_sdk/local_sandbox.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@
2929
from pathlib import Path
3030
from typing import Any, Dict, List, Optional
3131

32+
_MAX_PARAM_LEN = 120
33+
34+
35+
def _truncate(value: Any, max_len: int = _MAX_PARAM_LEN) -> str:
36+
"""Return a short string repr of *value*, truncating if needed."""
37+
s = repr(value)
38+
if len(s) > max_len:
39+
return s[:max_len] + "..."
40+
return s
41+
3242
from predicators.agent_sdk.docker_sandbox import (
3343
_SANDBOX_SETTINGS,
3444
_VALIDATE_SANDBOX_SCRIPT,
@@ -298,7 +308,13 @@ async def query(self, message: str) -> List[Dict[str, Any]]:
298308
"name": block.name,
299309
"input": block.input,
300310
})
301-
logging.debug("Agent tool call: %s", block.name)
311+
params = block.input or {}
312+
param_summary = ", ".join(
313+
f"{k}={_truncate(v)}"
314+
for k, v in params.items())
315+
logging.debug(
316+
"Agent tool call: %s(%s)",
317+
block.name, param_summary)
302318
else:
303319
block_type = type(block).__name__
304320
block_dict: Dict[str, Any] = {"type": block_type}

predicators/agent_sdk/session_manager.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77

88
from predicators.settings import CFG
99

10+
_MAX_PARAM_LEN = 120
11+
12+
13+
def _truncate(value: Any, max_len: int = _MAX_PARAM_LEN) -> str:
14+
"""Return a short string repr of *value*, truncating if needed."""
15+
s = repr(value)
16+
if len(s) > max_len:
17+
return s[:max_len] + "..."
18+
return s
19+
1020

1121
class AgentSessionManager:
1222
"""Wraps ClaudeSDKClient for persistent sessions with custom MCP tools."""
@@ -135,7 +145,13 @@ async def query(self, message: str) -> List[Dict[str, Any]]:
135145
"input":
136146
block.input,
137147
})
138-
logging.debug(f"Agent tool call: {block.name}")
148+
params = block.input or {}
149+
param_summary = ", ".join(
150+
f"{k}={_truncate(v)}"
151+
for k, v in params.items())
152+
logging.debug(
153+
"Agent tool call: %s(%s)",
154+
block.name, param_summary)
139155
collected.append(entry)
140156
elif isinstance(msg, UserMessage):
141157
user_entry: Dict[str, Any] = {"type": "user", "content": []}

scripts/configs/predicatorv3/predicator_v3.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ APPROACHES:
3333
demonstrator: "oracle_process_planning"
3434
terminate_on_goal_reached_and_option_terminated: True
3535
agent_planner_isolate_test_session: True
36-
agent_sdk_use_docker_sandbox: True
37-
# agent_sdk_use_local_sandbox: True
36+
# agent_sdk_use_docker_sandbox: True
37+
agent_sdk_use_local_sandbox: True
3838
agent_sdk_max_agent_turns_per_iteration: 40
3939
# mb_agent:
4040
# NAME: "agent_abstraction_learning"

0 commit comments

Comments
 (0)