CodeTriage Agent
The CodeTriage agent performs root cause analysis by reading source code and using multi-turn LLM prompting.
Responsibilities
Section titled “Responsibilities”- Clone the target repository in a Sandbox
- Read source code relevant to the error
- Perform LLM-powered root cause analysis
- Validate results with a second-opinion model for low-confidence findings
- Route incidents to FixAgent or mark as
needs_human
How It Works
Section titled “How It Works”Analysis Pipeline
Section titled “Analysis Pipeline”- Receive a
TriageReadyMessagefrom the queue - Clone the repository in a Sandbox container
- Read the entry point source code (
src/index.ts) - Send a structured prompt to Workers AI requesting JSON output:
{ "rootCauseFile": "src/handlers/auth.ts", "rootCauseLines": [42, 58], "rootCauseExplanation": "The JWT validation function doesn't handle expired tokens...", "fixStrategy": "Add a check for TokenExpiredError before the general catch block...", "confidence": "high", "affectedFiles": ["src/handlers/auth.ts", "src/middleware/auth.ts"]}Confidence Validation
Section titled “Confidence Validation”If the initial analysis returns low confidence:
- A second LLM call is made using a different model (Llama 3.3 70B)
- The second model reviews the first analysis and either confirms or revises it
- If confidence remains
lowafter validation, the incident is markedneeds_human
Routing
Section titled “Routing”| Confidence | Action |
|---|---|
high or medium | Publish to fix-ready queue |
low (after validation) | Mark needs_human |
LLM Models
Section titled “LLM Models”| Purpose | Model |
|---|---|
| Initial analysis | Workers AI default (Llama 3.3 70B) |
| Validation | @cf/meta/llama-3.3-70b-instruct-fp8-fast |
All LLM calls are recorded in the llm_calls D1 table for cost tracking and audit.
HTTP Endpoints
Section titled “HTTP Endpoints”| Method | Path | Description |
|---|---|---|
POST | /triage | Triage an incident from a queue message |
GET | /status | Current agent state |