Skip to content

refactor(engine): consolidate prompt entry into RunRequest #461

Closed

Description

@JAORMX

Problem

The importable engine currently exposes three normal prompt-entry methods:

  • Engine.Run for text
  • Engine.RunContent for text plus media
  • Engine.RunContentWith for 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,
) *Run

RunRequest carries:

  • text input;
  • optional multimodal []session.Content parts;
  • 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

  1. Add the neutral RunRequest value object in engine/agent.
  2. Replace Run, RunContent, and RunContentWith with the single canonical Run method.
  3. Route the new method through the existing startRun/drive implementation without changing loop behavior.
  4. Update all core, adapter, service, demo, performance, and test callers.
  5. Keep ResumeApproval behavior and signature distinct.
  6. Update the engine API compatibility baseline and classify the change in engine/CHANGELOG.md per engine/COMPATIBILITY.md.
  7. 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 ResumeApproval into RunRequest.
  • Implementing the execution-environment refactor; that is the follow-up phase.

Acceptance criteria

  1. The exported engine API has exactly one normal prompt-entry method named Run.
  2. A text-only run is expressible with only RunRequest.Text populated.
  3. A multimodal run accepts the same validated session.Content parts and preserves current command-expansion/hook/media behavior.
  4. Every current RunOptions behavior is representable in RunRequest with unchanged tighten-only, extra-tool overlay, and ask-ID validation semantics.
  5. ResumeApproval remains a separate awaiting-only entry point and all restart/resume tests remain green.
  6. All production callers and tests use the canonical method; no RunContent or RunContentWith symbols remain.
  7. task api:check, task lint, task test, and the offline go run ./cmd/mecademo smoke test pass.
  8. The API baseline and engine/CHANGELOG.md explicitly 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

  1. self-assigned this
    on Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions