Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ test_debug_*.py
test_performance_*.py
test_user_*.py
test_new_*.py
test_roocode_compatibility.py
test_roocode_compatibility.py.hypothesis/
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 49 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ sse-starlette = "^2.1.3"
python-multipart = "^0.0.18"
claude-agent-sdk = "^0.1.18"
slowapi = "^0.1.9"
anthropic = "^0.79.0"
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anthropic is added as a runtime dependency, but it doesn't appear to be imported/used anywhere in src/ right now. If it isn't required for this PR, consider removing it to avoid extra install size and dependency surface area.

Suggested change
anthropic = "^0.79.0"

Copilot uses AI. Check for mistakes.

[tool.poetry.group.dev.dependencies]
black = "^24.0.0"
Expand Down
16 changes: 11 additions & 5 deletions src/claude_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ async def run_completion(
session_id: Optional[str] = None,
continue_session: bool = False,
permission_mode: Optional[str] = None,
mcp_servers: Optional[Dict[str, Any]] = None,
) -> AsyncGenerator[Dict[str, Any], None]:
"""Run Claude Agent using the Python SDK and yield response chunks."""

Expand All @@ -123,13 +124,14 @@ async def run_completion(
if model:
options.model = model

# Set system prompt - CLAUDE AGENT SDK STRUCTURED FORMAT
# Use structured format as per SDK documentation
# Set system prompt
# SDK's _build_command only handles: None, str, or {"type": "preset", "append": "..."}
# Passing a plain string ensures --system-prompt flag is added to CLI command
if system_prompt:
options.system_prompt = {"type": "text", "text": system_prompt}
options.system_prompt = system_prompt
else:
# Use Claude Code preset to maintain expected behavior
options.system_prompt = {"type": "preset", "preset": "claude_code"}
# No custom prompt - let Claude Code use its default behavior
options.system_prompt = None

# Set tool restrictions
if allowed_tools:
Expand All @@ -141,6 +143,10 @@ async def run_completion(
if permission_mode:
options.permission_mode = permission_mode

# Set MCP servers (for OpenClaw tool bridge)
if mcp_servers:
options.mcp_servers = mcp_servers

# Handle session continuity
if continue_session:
options.continue_session = True
Expand Down
32 changes: 21 additions & 11 deletions src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ async def chat_endpoint(): ...
"Edit",
]

# Tools to allow in passthrough mode (agent frameworks like OpenClaw)
# Broader set including network tools needed for agent functionality
PASSTHROUGH_ALLOWED_TOOLS = [
"Read",
"Glob",
"Grep",
"Bash",
"Write",
"Edit",
"WebFetch",
"WebSearch",
"NotebookEdit",
"Task",
]

# Tools to disallow by default (potentially dangerous or slow)
DEFAULT_DISALLOWED_TOOLS = [
"Task", # Can spawn sub-agents
Expand All @@ -69,26 +84,21 @@ async def chat_endpoint(): ...
# Models supported by Claude Agent SDK (as of November 2025)
# NOTE: Claude Agent SDK only supports Claude 4+ models, not Claude 3.x
CLAUDE_MODELS = [
# Claude 4.5 Family (Latest - Fall 2025) - RECOMMENDED
"claude-opus-4-5-20250929", # Latest Opus 4.5 - Most capable
"claude-sonnet-4-5-20250929", # Recommended - best coding model
# Claude 4.6 (Latest - February 2026)
"claude-opus-4-6", # Latest Opus 4.6 - Most capable
# Claude 4.5 Family (Fall 2025)
"claude-sonnet-4-5-20250929", # Best coding model
"claude-haiku-4-5-20251001", # Fast & cheap
# Claude 4.1
"claude-opus-4-1-20250805", # Upgraded Opus 4
"claude-opus-4-1-20250805",
# Claude 4.0 Family (Original - May 2025)
"claude-opus-4-20250514",
"claude-sonnet-4-20250514",
# Claude 3.x Family - NOT SUPPORTED by Claude Agent SDK
# These models work with Anthropic API but NOT with Claude Code
# Uncomment only if using direct Anthropic API (not Claude Agent SDK)
# "claude-3-7-sonnet-20250219",
# "claude-3-5-sonnet-20241022",
# "claude-3-5-haiku-20241022",
]

# Default model (recommended for most use cases)
# Can be overridden via DEFAULT_MODEL environment variable
DEFAULT_MODEL = os.getenv("DEFAULT_MODEL", "claude-sonnet-4-5-20250929")
DEFAULT_MODEL = os.getenv("DEFAULT_MODEL", "claude-opus-4-6")

# Fast model (for speed/cost optimization)
FAST_MODEL = "claude-haiku-4-5-20251001"
Expand Down
Loading
Loading