Skip to content

Migrate agent orchestration from CrewAI to Claude agent runtime (Anthropic SDK tool-use loop)#115

Draft
eovidiu wants to merge 6 commits into
mainfrom
claude/claude-sdk-agent-migration-lxxan0
Draft

Migrate agent orchestration from CrewAI to Claude agent runtime (Anthropic SDK tool-use loop)#115
eovidiu wants to merge 6 commits into
mainfrom
claude/claude-sdk-agent-migration-lxxan0

Conversation

@eovidiu

@eovidiu eovidiu commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Summary

Revives the project by replacing the CrewAI / LiteLLM / LangChain orchestration layer with a self-hosted Claude agent runtime built directly on the Anthropic SDK (Messages API + tool-use loop). The backend already talked to Claude directly via llm_service; CrewAI was a redundant, heavyweight parallel path (memory disabled, no tools wired). This removes that stack and gives us a clean, extensible agent loop.

Full plan and rationale: see MIGRATION.md.

What changed

New

  • backend/app/services/agent_runtime.pyAgentRuntime: agentic tool-use loop for single- and multi-agent (sequential/hierarchical) execution. Prompt-injection sanitization, tenacity retries, token-usage aggregation across iterations, and an extensible TOOL_HANDLERS/build_tools registry (empty today, ready for real tools).
  • backend/tests/unit/test_agent_runtime.py, MIGRATION.md.

Modified

  • Celery worker → AgentRuntime.execute_agent_task (signatures match the former CrewService, so it's a drop-in).
  • Model-aware requests: omit temperature/top_p for Claude 4.6+/Fable models (they 400 on sampling params) in both the runtime and llm_service; fix the retired validation-ping model; refresh the pricing table.
  • Default model → claude-opus-4-8; current Claude models added to the provider registry; retired snapshot IDs remapped to current models so existing seeded agents keep working.
  • Removed crewai/litellm/langchain-* from requirements.txt + pyproject.toml; dropped CrewAI notes from Dockerfiles; bumped the worker cache buster.
  • Docs (README.md, CI review prompt) updated.

Removed

  • backend/app/services/crew_service.py and its unit test.

Behavioral notes / scope

  • Multi-provider execution change: the runtime executes Anthropic models only and returns a clear error for other providers (CrewAI/LiteLLM was what enabled cross-provider execution). OpenAI/Mistral remain in the registry as metadata. See MIGRATION.md §3/§8.
  • No DB schema or API-contract changes — task input/output shapes are unchanged, so rollback is a clean git revert.

Testing

  • New test_agent_runtime.py covers helpers, model resolution (rejects non-Anthropic), happy path, temperature inclusion/omission by model family, the tool-use loop, unknown-tool error handling, and multi-agent chaining/validation.
  • Integration + websocket tests retargeted to AgentRuntime.
  • Validated locally (with the SDK mocked): all runtime checks pass; retired-ID remapping and current-model validation confirmed. The sandbox lacks a working cryptography rust binding and full deps, so the suite wasn't run via pytest here — see MIGRATION.md §6 for the command to run in CI / a configured env.

Follow-ups (out of scope, documented)

  • Regenerate backend/uv.lock to match the slimmed pyproject.toml.
  • Optionally bump the anthropic floor and wire real tools (Phase 3).

https://claude.ai/code/session_01PBZ9ZzrmJdAcZQbKZABRN9


Generated by Claude Code

claude added 6 commits June 16, 2026 12:50
Replace the CrewAI/LiteLLM/LangChain orchestration layer with a self-hosted
Claude agent runtime built directly on the Anthropic SDK (Messages API +
tool-use loop).

- Add AgentRuntime (app/services/agent_runtime.py): agentic tool-use loop for
  single- and multi-agent (sequential/hierarchical) execution, with prompt
  sanitization, tenacity retries, token-usage aggregation, and an extensible
  tool registry (empty today).
- Wire the Celery worker to AgentRuntime; remove CrewService.
- Make LLM requests model-aware: omit sampling params for Claude 4.6+/Fable
  models (which 400 on temperature/top_p); fix the retired validation-ping
  model and refresh pricing.
- Update default model to claude-opus-4-8; add current Claude models to the
  provider registry; remap retired snapshot IDs to current models so seeded
  agents keep working.
- Remove crewai/litellm/langchain deps from requirements.txt and pyproject.toml;
  drop CrewAI build notes from Dockerfiles.
- Replace crew_service tests with agent_runtime tests; retarget websocket and
  api-key integration tests to AgentRuntime.
- Add MIGRATION.md documenting the transition, phased rollout, and follow-ups.

https://claude.ai/code/session_01PBZ9ZzrmJdAcZQbKZABRN9
Format the two files introduced/edited by the migration to satisfy the
Code Quality job (black --line-length=100, isort --profile black). No logic
change.

https://claude.ai/code/session_01PBZ9ZzrmJdAcZQbKZABRN9
Note the black drift (unpinned black in ci.yml over untouched files) and the
missing backend/entrypoint.sh Docker build failure in MIGRATION.md §8. Both
pre-date this migration and are deferred to a separate cleanup PR to keep this
diff focused; Run Tests is green.

https://claude.ai/code/session_01PBZ9ZzrmJdAcZQbKZABRN9
Reformat pre-existing formatting/import-order drift across backend/app so the
CI lint job (black --line-length=100, isort --profile black) passes. The
workflow installs unpinned black (now 26.5.1)/isort, which had drifted from the
last-formatted state on files this migration didn't otherwise touch. Purely
cosmetic — import reordering and line wrapping, no logic changes.

Recommend pinning black/isort versions in ci.yml as a follow-up.

https://claude.ai/code/session_01PBZ9ZzrmJdAcZQbKZABRN9
backend/Dockerfile COPYs paths relative to the repo root (COPY backend/app
./app, ... COPY backend/entrypoint.sh), matching how Railway builds it, but the
CI build job passed context: ./backend — so COPY backend/entrypoint.sh resolved
to backend/backend/entrypoint.sh and failed with "not found". The file (and all
other COPY sources) exists at the repo root; the context was wrong.

Set the backend build step's context to the repo root (the frontend step
already uses context: .). No Dockerfile change needed.

https://claude.ai/code/session_01PBZ9ZzrmJdAcZQbKZABRN9
The Claude review action rejects any PR that modifies its own workflow file
("Workflow validation failed. The workflow file must exist and have identical
content to the version on the repository's default branch."). This PR's earlier
cosmetic edits to the review prompt (CrewAI -> Claude wording) triggered that
401. Revert them so the review action can run; the wording update belongs in a
separate change that lands on main directly.

https://claude.ai/code/session_01PBZ9ZzrmJdAcZQbKZABRN9
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.

2 participants