Migrate agent orchestration from CrewAI to Claude agent runtime (Anthropic SDK tool-use loop)#115
Draft
eovidiu wants to merge 6 commits into
Draft
Migrate agent orchestration from CrewAI to Claude agent runtime (Anthropic SDK tool-use loop)#115eovidiu wants to merge 6 commits into
eovidiu wants to merge 6 commits into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.py—AgentRuntime: agentic tool-use loop for single- and multi-agent (sequential/hierarchical) execution. Prompt-injection sanitization, tenacity retries, token-usage aggregation across iterations, and an extensibleTOOL_HANDLERS/build_toolsregistry (empty today, ready for real tools).backend/tests/unit/test_agent_runtime.py,MIGRATION.md.Modified
AgentRuntime.execute_agent_task(signatures match the formerCrewService, so it's a drop-in).temperature/top_pfor Claude 4.6+/Fable models (they 400 on sampling params) in both the runtime andllm_service; fix the retired validation-ping model; refresh the pricing table.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.crewai/litellm/langchain-*fromrequirements.txt+pyproject.toml; dropped CrewAI notes from Dockerfiles; bumped the worker cache buster.README.md, CI review prompt) updated.Removed
backend/app/services/crew_service.pyand its unit test.Behavioral notes / scope
MIGRATION.md§3/§8.git revert.Testing
test_agent_runtime.pycovers 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.AgentRuntime.cryptographyrust binding and full deps, so the suite wasn't run viapytesthere — seeMIGRATION.md§6 for the command to run in CI / a configured env.Follow-ups (out of scope, documented)
backend/uv.lockto match the slimmedpyproject.toml.anthropicfloor and wire real tools (Phase 3).https://claude.ai/code/session_01PBZ9ZzrmJdAcZQbKZABRN9
Generated by Claude Code