Skip to content

Commit 09770bb

Browse files
debug: test claude --version before running, add --max-turns 10 (#34)
1 parent aaabb69 commit 09770bb

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/policyengine_api/agent_sandbox.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,25 @@ def run_claude_code_in_sandbox(
140140
config=verify_process.stdout.read()[:500],
141141
)
142142

143+
# Test Claude CLI works at all
144+
print("[SANDBOX] Testing claude --version", flush=True)
145+
logfire.info("run_claude_code_in_sandbox: testing claude --version")
146+
version_check = sb.exec("claude", "--version")
147+
version_check.wait()
148+
version_stdout = version_check.stdout.read()
149+
version_stderr = version_check.stderr.read()
150+
print(f"[SANDBOX] claude --version: stdout={version_stdout}, stderr={version_stderr}, rc={version_check.returncode}", flush=True)
151+
logfire.info(
152+
"run_claude_code_in_sandbox: claude --version result",
153+
stdout=version_stdout[:200] if version_stdout else None,
154+
stderr=version_stderr[:500] if version_stderr else None,
155+
returncode=version_check.returncode,
156+
)
157+
143158
# Run Claude Code with the question
144159
# --dangerously-skip-permissions: auto-accept permission prompts (required for non-interactive)
160+
# --max-turns: limit execution to prevent runaway
161+
print("[SANDBOX] Starting claude CLI with question", flush=True)
145162
logfire.info("run_claude_code_in_sandbox: starting claude CLI")
146163
process = sb.exec(
147164
"claude",
@@ -151,9 +168,12 @@ def run_claude_code_in_sandbox(
151168
"stream-json",
152169
"--verbose",
153170
"--dangerously-skip-permissions",
171+
"--max-turns",
172+
"10",
154173
"--allowedTools",
155174
"mcp__policyengine__*,Bash,Read,Grep,Glob,Write,Edit",
156175
)
176+
print("[SANDBOX] claude CLI process started", flush=True)
157177
logfire.info("run_claude_code_in_sandbox: claude CLI process started, returning")
158178

159179
return sb, process

0 commit comments

Comments
 (0)