Repository navigation
Description
Problem
The importable engine currently exposes three normal prompt-entry methods:
Engine.Runfor textEngine.RunContentfor text plus mediaEngine.RunContentWithfor text plus media plus per-run options
They are implementation delegates over the same startRun path, but they make callers choose among three names for one operation and increase the public compatibility surface. Multimodality and per-run controls are properties of a run request, not separate operations.
Decision
Consolidate the three methods into one canonical entry point:
func (e *Engine) Run(
ctx context.Context,
sess *session.Session,
env tool.ExecutionEnvironment, // or the current Workspace until phase 2 lands
req RunRequest,
) *RunRunRequest carries:
- text input;
- optional multimodal
[]session.Contentparts; - the current per-run token ceiling override;
- run-scoped extra tools;
- the ask-ID discriminator.
Use a request struct rather than variadic functional options. The zero values preserve the current default behavior.
Keep ResumeApproval separate: it resumes a persisted session at an existing awaiting approval and does not start a new prompt.
This is an intentional breaking change to the engine API. Do not preserve the three-way API indefinitely merely as aliases.
Scope
- Add the neutral
RunRequestvalue object inengine/agent. - Replace
Run,RunContent, andRunContentWithwith the single canonicalRunmethod. - Route the new method through the existing
startRun/driveimplementation without changing loop behavior. - Update all core, adapter, service, demo, performance, and test callers.
- Keep
ResumeApprovalbehavior and signature distinct. - Update the engine API compatibility baseline and classify the change in
engine/CHANGELOG.mdperengine/COMPATIBILITY.md. - Update architecture and usage documentation where the engine embedding API is shown; regenerate
llms.txt.
Non-goals
- Changing run-loop behavior, state transitions, streaming, permissions, compaction, or event semantics.
- Converting per-run controls to functional options.
- Folding
ResumeApprovalintoRunRequest. - Implementing the execution-environment refactor; that is the follow-up phase.
Acceptance criteria
- The exported engine API has exactly one normal prompt-entry method named
Run. - A text-only run is expressible with only
RunRequest.Textpopulated. - A multimodal run accepts the same validated
session.Contentparts and preserves current command-expansion/hook/media behavior. - Every current
RunOptionsbehavior is representable inRunRequestwith unchanged tighten-only, extra-tool overlay, and ask-ID validation semantics. ResumeApprovalremains a separate awaiting-only entry point and all restart/resume tests remain green.- All production callers and tests use the canonical method; no
RunContentorRunContentWithsymbols remain. task api:check,task lint,task test, and the offlinego run ./cmd/mecademosmoke test pass.- The API baseline and
engine/CHANGELOG.mdexplicitly record the intentional breaking change.
Sequencing
This is phase 1. Land it before the execution-environment refactor so the later Workspace → environment signature change only touches one normal run method.
Activity