{"id":"agentica-claude-proxy","name":"agentica-claude-proxy","summary":"Agentica SDKとClaude Code CLIプロキシの統合ガイド","body":"# Agentica-Claude Code Proxy Integration\n\nUse this skill when developing or debugging the Agentica-Claude proxy integration.\n\n## When to Use\n\n- Setting up Agentica agents to use Claude Code tools\n- Debugging agent hallucination issues\n- Fixing permission errors in file operations\n- Understanding the REPL response format\n\n## Architecture Overview\n\n```\nAgentica Agent → S_M_BASE_URL → Claude Proxy → claude -p → Claude CLI (with tools)\n                 (localhost:2345)   (localhost:8080)\n```\n\n## Critical Requirements\n\n### 1. --allowedTools Flag (REQUIRED)\n\nClaude CLI in `-p` mode restricts file operations. You MUST add:\n\n```python\nsubprocess.run([\n    \"claude\", \"-p\", prompt,\n    \"--append-system-prompt\", system_prompt,\n    \"--allowedTools\", \"Read\", \"Write\", \"Edit\", \"Bash\",  # REQUIRED\n])\n```\n\nWithout this, agents will report \"permission denied\" for Write/Edit operations.\n\n### 2. SSE Streaming Format (REQUIRED)\n\nAgentica expects SSE streaming, not plain JSON:\n\n```python\n# Response format\nyield f\"data: {json.dumps(chunk)}\\n\\n\"\nyield \"data: [DONE]\\n\\n\"\n```\n\n### 3. REPL Response Format (REQUIRED)\n\nAgents MUST return results as Python code blocks with a return statement:\n\n```python\nreturn \"your result here\"\n```\n\nAgentica's REPL parser extracts code between \\`\\`\\`python and \\`\\`\\`.\n\n## Anti-Hallucination Prompt Engineering\n\nAgents will hallucinate success without actually using tools unless you explicitly warn them:\n\n```\n## ANTI-HALLUCINATION WARNING\n\n**STOP AND READ THIS CAREFULLY:**\n\nYou have access to these tools: Read, Write, Edit, Bash\n\nWhen the task asks you to create/modify/run something:\n1. FIRST: Actually invoke the tool (Read, Write, Edit, or Bash)\n2. SECOND: Wait for the tool result\n3. THIRD: Then return your answer based on what actually happened\n\n**DO NOT** skip the tool invocation and just claim success!\n\nIf you didn't invoke a tool, you CANNOT claim the action succeeded.\n```\n\n## Path Sandboxing\n\nBoth Claude Code and Agentica have sandboxes:\n\n- `/tmp/` paths are blocked by Claude Code\n- Files outside project directory blocked by Agentica\n\n**Solution:** Use project-relative paths like `workspace/` instead of `/tmp/`\n\n## Debugging\n\n### Check Agent Logs\n\n```bash\ncat logs/agent-<N>.log\n```\n\nNote: Logs only show final conversational response, not tool invocations.\n\n### Test Proxy Directly\n\n```bash\ncurl -s http://localhost:8080/v1/chat/completions \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"model\": \"claude\", \"messages\": [{\"role\": \"user\", \"content\": \"Create file at workspace/test.txt\"}], \"stream\": false}'\n```\n\n### Verify File Operations\n\n```bash\n# After agent claims to create file\nls -la workspace/test.txt\ncat workspace/test.txt\n```\n\n## Server Commands\n\n### Start Servers\n\n```bash\n# Terminal 1: Proxy\nuv run python scripts/agentica/claude_proxy.py --port 8080\n\n# Terminal 2: Agentica Server\ncd workspace/agentica-research/agentica-server\nINFERENCE_ENDPOINT_URL=http://localhost:8080/v1/chat/completions uv run agentica-server --port 2345\n```\n\n### Use Swarm\n\n```bash\nS_M_BASE_URL=http://localhost:2345 uv run python your_script.py\n```\n\n### Health Checks\n\n```bash\ncurl http://localhost:8080/health  # Proxy\ncurl http://localhost:2345/health  # Agentica\n```\n\n## Reference Files\n\n- Proxy implementation: `scripts/agentica/claude_proxy.py`\n- REPL_BASELINE prompt: `scripts/agentica/claude_proxy.py:49-155`\n- Comprehensive test: `workspace/test_swarm_all_tools.py`\n- DependencySwarm: `scripts/agentica/dependency_swarm.py`\n\n## Common Errors\n\n| Error | Cause | Fix |\n|-------|-------|-----|\n| \"Permission denied\" | Missing --allowedTools | Add `--allowedTools Read Write Edit Bash` |\n| Agent claims success but file not created | Hallucination | Add anti-hallucination prompt section |\n| \"Cannot access /tmp/...\" | Sandbox restriction | Use project-relative paths |\n| \"APIConnectionError\" | Wrong response format | Use SSE streaming (data: {...}\\n\\n) |\n| \"NameError: view_file\" | Agent using REPL functions | Add REPL_BASELINE with native tool examples |","author":"@parcadei","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/parcadei/Continuous-Claude-v3/tree/main/.claude/skills/agentica-claude-proxy","license":"MIT","category":"writing","lang":"en","tokens":1006,"stars":0,"calls30d":0,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[],"requires":{"mcp":[],"tools":["Read","Bash"]},"safety":{"flags":[],"scannedAt":"2026-08-22","hasScripts":false,"networkEndpoints":[]}}