Skip to content

[P1] Implement WorkerAgent.execute_task() with Anthropic API integration #98

Description

@frankbria

Overview

The core task execution method in WorkerAgent is currently stubbed with a TODO comment. This prevents agents from actually executing tasks autonomously.

Current State

File: codeframe/agents/worker_agent.py lines 97-99

# TODO: Implement task execution with LLM provider
# TODO: Add token tracking after LLM call (see docstring example)
return {"status": "completed", "output": "Task executed successfully"}

Expected Behavior

  • Initialize AsyncAnthropic client with API key from environment
  • Construct prompt from task description and context
  • Make LLM API call using Claude Sonnet 4.5 (or configurable model)
  • Parse response and extract task output
  • Handle errors gracefully (rate limits, network issues, etc.)
  • Return structured result with status and output

Implementation Requirements

  1. Use AsyncAnthropic client for async API calls
  2. Follow the pattern shown in docstring example
  3. Include proper error handling and retries
  4. Use streaming for long responses (optional enhancement)
  5. Support model selection via configuration

Acceptance Criteria

  • execute_task() makes actual Anthropic API calls
  • Token usage is tracked and returned in response
  • Error handling covers rate limits, network issues, invalid responses
  • Unit tests verify API call construction (mocked)
  • Integration tests verify end-to-end task execution (real API)

Priority

P1 - Critical: Without this, workers cannot perform their primary function of autonomous task execution.

References

  • User Documentation: CODEFRAME_USER_DOCUMENTATION.md lines 16-21
  • Issues Analysis: CODEFRAME_ISSUES_ANALYSIS.md lines 11-20

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions