Skip to content

Add Claude Managed Agents and Cursor SDK providers for trading agents - #145

Open
anthonyrs06 wants to merge 2 commits into
hummingbot:mainfrom
anthonyrs06:feat/managed-and-cursor-sdk-providers
Open

Add Claude Managed Agents and Cursor SDK providers for trading agents#145
anthonyrs06 wants to merge 2 commits into
hummingbot:mainfrom
anthonyrs06:feat/managed-and-cursor-sdk-providers

Conversation

@anthonyrs06

Copy link
Copy Markdown

Context

TickEngine currently supports two LLM provider families via agent_key: ACP subprocess agents (claude-code, gemini, ...) that rebuild the full prompt each tick, and PydanticAI direct-API models. Neither offers a persistent conversation — every tick starts from a cold context, so the agent has no native memory of earlier ticks beyond what the journal re-injects.

Change

Two new opt-in providers with persistent sessions and local tool execution:

claude-managed[:<model>] — runs the brain on Anthropic's hosted Managed Agents harness:

  • One hosted conversation per Condor session; ticks are follow-up messages (harness handles compaction/caching), so only dynamic state is sent per tick (build_managed_tick_prompt)
  • Cross-session memory store mounted at /mnt/memory in the agent sandbox — the self-learning loop survives restarts
  • Trading tools exposed as custom tools through a new McpToolBridge (condor/acp/managed_tools.py): the hosted agent emits tool requests, Condor executes them locally through the same MCP servers, gated by the existing auto_approve_with_risk_check callback. Credentials never leave the machine; dry-run/risk blocking behaves identically to other providers
  • Wedged hosted sessions (which otherwise dead-loop silently) are rotated automatically after 3 consecutive tick timeouts, with user notification

cursor-managed[:<model>] — runs the brain on the Cursor SDK local runtime:

  • Persistent local conversation per session; filesystem memory under the agent directory (memory/playbooks.md, mistakes.md, regimes.md)
  • Same MCP bridge + risk gating as above
  • Auto-recovery: send() retries once after resetting the SDK bridge and rotating the persisted agent on InternalServerError/ConnectError; the engine rotates after 2 consecutive provider errors; new sessions always provision a fresh remote conversation; starting a second cursor-managed session for the same agent returns 409

Risks

  • Zero impact when unused — both providers are opt-in via agent_key; existing ACP/PydanticAI paths are untouched apart from a shared prompt-branch condition
  • New deps (anthropic>=0.109.1, cursor-sdk>=0.1.8) are import-guarded inside the provider modules
  • All recovery paths are covered by unit tests with faked SDK clients — no network in CI (29 tests added)

Rollout

  • Docs: provider sections + troubleshooting table in condor/trading_agent/README.md
  • Requires ANTHROPIC_API_KEY (claude-managed) / CURSOR_API_KEY (cursor-managed)

Test plan

  • pytest tests/ — 29 passed (managed tool bridge, session rotation, cursor client event mapping, permission blocking, bridge recovery, engine routing)
  • import condor.trading_agent.engine / condor.web.routes.agents clean
  • Live validation on a fork: both providers ran multi-day BTC-perp paper/live sessions (60+ ticks per session) including automatic recovery from a wedged Cursor bridge and a stale remote agent

Made with Cursor

anthonyrs06 and others added 2 commits July 1, 2026 17:57
…essions

New agent_key provider that runs the trading brain on Anthropic's hosted
Managed Agents harness: persistent conversation per session, cross-session
memory store, and local tool execution via an MCP-to-custom-tool bridge
gated by the existing risk permission callback. Wedged hosted sessions are
rotated automatically after consecutive tick timeouts.

Co-authored-by: Cursor <cursoragent@cursor.com>
Runs the trading brain on the Cursor SDK local runtime with a persistent
conversation per Condor session and filesystem memory under the agent
directory. Recovers automatically from wedged bridges and remote agents:
send() retries once after resetting the bridge and rotating the persisted
agent on InternalServerError/ConnectError, the engine rotates after
consecutive provider errors, and starting a second cursor-managed session
for the same agent returns 409.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant