$npx -y skills add vibeeval/vibecosystem --skill agentica-claude-proxy--- name: agentica-claude-proxy description: Guide for integrating Agentica SDK with Claude Code CLI proxy allowed-tools: [Read, Bash] user-invocable: false ---
| 1 | # Agentica-Claude Code Proxy Integration |
| 2 | |
| 3 | Use this skill when developing or debugging the Agentica-Claude proxy integration. |
| 4 | |
| 5 | ## When to Use |
| 6 | |
| 7 | - Setting up Agentica agents to use Claude Code tools |
| 8 | - Debugging agent hallucination issues |
| 9 | - Fixing permission errors in file operations |
| 10 | - Understanding the REPL response format |
| 11 | |
| 12 | ## Architecture Overview |
| 13 | |
| 14 | ``` |
| 15 | Agentica Agent → S_M_BASE_URL → Claude Proxy → claude -p → Claude CLI (with tools) |
| 16 | (localhost:2345) (localhost:8080) |
| 17 | ``` |
| 18 | |
| 19 | ## Critical Requirements |
| 20 | |
| 21 | ### 1. --allowedTools Flag (REQUIRED) |
| 22 | |
| 23 | Claude CLI in `-p` mode restricts file operations. You MUST add: |
| 24 | |
| 25 | ```python |
| 26 | subprocess.run([ |
| 27 | "claude", "-p", prompt, |
| 28 | "--append-system-prompt", system_prompt, |
| 29 | "--allowedTools", "Read", "Write", "Edit", "Bash", # REQUIRED |
| 30 | ]) |
| 31 | ``` |
| 32 | |
| 33 | Without this, agents will report "permission denied" for Write/Edit operations. |
| 34 | |
| 35 | ### 2. SSE Streaming Format (REQUIRED) |
| 36 | |
| 37 | Agentica expects SSE streaming, not plain JSON: |
| 38 | |
| 39 | ```python |
| 40 | # Response format |
| 41 | yield f"data: {json.dumps(chunk)}\n\n" |
| 42 | yield "data: [DONE]\n\n" |
| 43 | ``` |
| 44 | |
| 45 | ### 3. REPL Response Format (REQUIRED) |
| 46 | |
| 47 | Agents MUST return results as Python code blocks with a return statement: |
| 48 | |
| 49 | ```python |
| 50 | return "your result here" |
| 51 | ``` |
| 52 | |
| 53 | Agentica's REPL parser extracts code between \`\`\`python and \`\`\`. |
| 54 | |
| 55 | ## Anti-Hallucination Prompt Engineering |
| 56 | |
| 57 | Agents will hallucinate success without actually using tools unless you explicitly warn them: |
| 58 | |
| 59 | ``` |
| 60 | ## ANTI-HALLUCINATION WARNING |
| 61 | |
| 62 | **STOP AND READ THIS CAREFULLY:** |
| 63 | |
| 64 | You have access to these tools: Read, Write, Edit, Bash |
| 65 | |
| 66 | When the task asks you to create/modify/run something: |
| 67 | 1. FIRST: Actually invoke the tool (Read, Write, Edit, or Bash) |
| 68 | 2. SECOND: Wait for the tool result |
| 69 | 3. THIRD: Then return your answer based on what actually happened |
| 70 | |
| 71 | **DO NOT** skip the tool invocation and just claim success! |
| 72 | |
| 73 | If you didn't invoke a tool, you CANNOT claim the action succeeded. |
| 74 | ``` |
| 75 | |
| 76 | ## Path Sandboxing |
| 77 | |
| 78 | Both Claude Code and Agentica have sandboxes: |
| 79 | |
| 80 | - `/tmp/` paths are blocked by Claude Code |
| 81 | - Files outside project directory blocked by Agentica |
| 82 | |
| 83 | **Solution:** Use project-relative paths like `workspace/` instead of `/tmp/` |
| 84 | |
| 85 | ## Debugging |
| 86 | |
| 87 | ### Check Agent Logs |
| 88 | |
| 89 | ```bash |
| 90 | cat logs/agent-<N>.log |
| 91 | ``` |
| 92 | |
| 93 | Note: Logs only show final conversational response, not tool invocations. |
| 94 | |
| 95 | ### Test Proxy Directly |
| 96 | |
| 97 | ```bash |
| 98 | curl -s http://localhost:8080/v1/chat/completions \ |
| 99 | -H "Content-Type: application/json" \ |
| 100 | -d '{"model": "claude", "messages": [{"role": "user", "content": "Create file at workspace/test.txt"}], "stream": false}' |
| 101 | ``` |
| 102 | |
| 103 | ### Verify File Operations |
| 104 | |
| 105 | ```bash |
| 106 | # After agent claims to create file |
| 107 | ls -la workspace/test.txt |
| 108 | cat workspace/test.txt |
| 109 | ``` |
| 110 | |
| 111 | ## Server Commands |
| 112 | |
| 113 | ### Start Servers |
| 114 | |
| 115 | ```bash |
| 116 | # Terminal 1: Proxy |
| 117 | uv run python scripts/agentica/claude_proxy.py --port 8080 |
| 118 | |
| 119 | # Terminal 2: Agentica Server |
| 120 | cd workspace/agentica-research/agentica-server |
| 121 | INFERENCE_ENDPOINT_URL=http://localhost:8080/v1/chat/completions uv run agentica-server --port 2345 |
| 122 | ``` |
| 123 | |
| 124 | ### Use Swarm |
| 125 | |
| 126 | ```bash |
| 127 | S_M_BASE_URL=http://localhost:2345 uv run python your_script.py |
| 128 | ``` |
| 129 | |
| 130 | ### Health Checks |
| 131 | |
| 132 | ```bash |
| 133 | curl http://localhost:8080/health # Proxy |
| 134 | curl http://localhost:2345/health # Agentica |
| 135 | ``` |
| 136 | |
| 137 | ## Reference Files |
| 138 | |
| 139 | - Proxy implementation: `scripts/agentica/claude_proxy.py` |
| 140 | - REPL_BASELINE prompt: `scripts/agentica/claude_proxy.py:49-155` |
| 141 | - Comprehensive test: `workspace/test_swarm_all_tools.py` |
| 142 | - DependencySwarm: `scripts/agentica/dependency_swarm.py` |
| 143 | |
| 144 | ## Common Errors |
| 145 | |
| 146 | | Error | Cause | Fix | |
| 147 | |-------|-------|-----| |
| 148 | | "Permission denied" | Missing --allowedTools | Add `--allowedTools Read Write Edit Bash` | |
| 149 | | Agent claims success but file not created | Hallucination | Add anti-hallucination prompt section | |
| 150 | | "Cannot access /tmp/..." | Sandbox restriction | Use project-relative paths | |
| 151 | | "APIConnectionError" | Wrong response format | Use SSE streaming (data: {...}\n\n) | |
| 152 | | "NameError: view_file" | Agent using REPL functions | Add REPL_BASELINE with native tool examples | |