Replace amp subprocess with native Engine in Worker

t-141.4·WorkTask·
·
·
·Omni/Agent/Worker.hs
Parent:t-141·Created3 months ago·Updated3 months ago

Dependencies

Description

Edit

Integrate Engine into Worker.hs:

New Function

runWithEngine :: FilePath -> TaskCore.Task -> IO (Exit.ExitCode, Text)

Implementation

1. Read OPENROUTER_API_KEY from environment 2. Build EngineConfig with:

  • LLM (openrouter.ai, key, model from complexity)
  • onCost callback -> update TaskActivity metrics
  • onActivity callback -> AgentLog.log

3. Build AgentConfig with:

  • Tools from Tools.allTools
  • System prompt (existing basePrompt logic)
  • User prompt (task description + context)
  • Max iterations (10 or configurable)

4. Inject existing context:

  • AGENTS.md content
  • Relevant facts (existing getRelevantFacts)
  • Task comments (existing formatComments)
  • Retry context if present

5. Call Engine.runAgent 6. Return success/failure based on result

Feature Flag

Add --use-engine flag to jr work command. Or JR_USE_ENGINE=1 environment variable. Default: still use amp (gradual rollout)

Preserve

  • Activity logging (Claiming, Running, Reviewing stages)
  • Cost/duration tracking
  • Retry handling

Timeline (0)

No activity yet.