Summary
Create codeframe/core/react_agent.py — the core ReAct loop agent that replaces Plan-and-Execute for code generation. This is the central module of the Phase 2.5 redesign.
Acceptance Criteria
ReactAgent class in codeframe/core/react_agent.py:
run(task_id: str) -> AgentState — main entry point
ReAct loop: LLM call with tools → execute tool calls → append results → repeat
Max 30 iterations hard cap
Termination: text-only response (no tool calls) = agent thinks it's done
Temperature 0.0 for deterministic execution
System prompt builder with 3-layer structure:
Layer 1 (Base) : Agent identity, tool descriptions (auto-generated from schemas), core rules, code quality constraints, termination conditions, decision-making autonomy
Layer 2 (Project) : AGENTS.md/CLAUDE.md content (from agents_config.py), tech stack, file tree summary
Layer 3 (Task) : Task title/description, PRD content (truncated to 5K), answered blockers
Conversation management: builds proper Anthropic API message format with tool_calls and tool_results
Intent preview: for HIGH complexity or greenfield tasks, system prompt instructs agent to outline approach before coding
Uses adapters/llm/base.py types: Tool, ToolCall, ToolResult
Delegates tool execution to tools.py:execute_tool()
Final verification: when agent stops calling tools, run all gates (ruff + pytest)
If final verification fails: re-enter loop for up to 5 more iterations with error context
Tests in tests/core/test_react_agent.py:
Loop terminates on text-only response
Loop terminates at max iterations
Tool calls dispatched correctly
System prompt contains all 3 layers
Final verification triggered on completion
Uses mock LLM provider for unit tests
All existing tests pass
Implementation Notes
The existing Agent class in agent.py is NOT modified — ReactAgent is a parallel implementation
Use MockLLMProvider from adapters/llm/mock.py for testing
Verify that the Anthropic adapter can handle multi-turn tool-use conversations (may need minor update to anthropic.py)
The system prompt rules from docs/AGENT_V3_UNIFIED_PLAN.md "Base Prompt (Layer 1)" section should be used verbatim
context.py:ContextLoader is reused for initial context loading
Dependencies
Subsumed Issues
Reference
docs/AGENT_V3_UNIFIED_PLAN.md (Architecture, System Prompt Design)
docs/REACT_AGENT_ARCHITECTURE.md (Section 2, 6)
docs/AGENT_ARCHITECTURE_CRITIQUE.md (Section 2.2 — hybrid approach)
Summary
Create
codeframe/core/react_agent.py— the core ReAct loop agent that replaces Plan-and-Execute for code generation. This is the central module of the Phase 2.5 redesign.Acceptance Criteria
ReactAgentclass incodeframe/core/react_agent.py:run(task_id: str) -> AgentState— main entry pointagents_config.py), tech stack, file tree summaryadapters/llm/base.pytypes:Tool,ToolCall,ToolResulttools.py:execute_tool()tests/core/test_react_agent.py:Implementation Notes
Agentclass inagent.pyis NOT modified — ReactAgent is a parallel implementationMockLLMProviderfromadapters/llm/mock.pyfor testinganthropic.py)docs/AGENT_V3_UNIFIED_PLAN.md"Base Prompt (Layer 1)" section should be used verbatimcontext.py:ContextLoaderis reused for initial context loadingDependencies
Subsumed Issues
Reference
docs/AGENT_V3_UNIFIED_PLAN.md(Architecture, System Prompt Design)docs/REACT_AGENT_ARCHITECTURE.md(Section 2, 6)docs/AGENT_ARCHITECTURE_CRITIQUE.md(Section 2.2 — hybrid approach)