Skip to content

Make AgentRunner the only Agent execution path#2161

Open
gold-silver-copper wants to merge 4 commits into
mainfrom
agent/enforce-agent-runner-execution
Open

Make AgentRunner the only Agent execution path#2161
gold-silver-copper wants to merge 4 commits into
mainfrom
agent/enforce-agent-runner-execution

Conversation

@gold-silver-copper

Copy link
Copy Markdown
Contributor

Summary

  • make AgentRunner the only execution path for configured Agent instances
  • remove the raw Completion and StreamingCompletion traits and their Agent implementations
  • keep raw, hook-free provider transport available explicitly through CompletionModel
  • make execution-critical Agent state private and add runner-backed per-request overrides
  • route Extractor through the full hook lifecycle while preserving retry, usage, schema, and provider request behavior
  • migrate manual AgentRun examples/tests to explicitly raw sans-I/O provider workflows

Why

Agent::completion() returned a mutable provider request builder without running the AgentRunner lifecycle. That allowed configured agent hooks, tool policies, termination, scratchpad state, and response/streaming events to be bypassed. A configured Agent should have one lowest-level execution path with one lifecycle contract.

Manual AgentRun examples remain intentionally provider-level sans-I/O workflows; this PR does not claim runner-backed durable stepping/checkpointing.

User impact

This is a breaking API change. Callers executing an Agent should use AgentRunner, Prompt, Chat, typed prompting, or streaming prompting. Callers that intentionally need raw provider transport should retain and call a CompletionModel directly.

Runner/request wrappers now expose history, temperature, max-token, additional-parameter, and tool-choice overrides without permitting post-hook request mutation.

Review findings addressed

An independent full-diff review found and this branch fixes:

  • StreamingPromptRequest::new discarded the Agent's configured hooks; it now preserves them, with a regression proving a terminating Agent hook prevents provider I/O.
  • non-object per-run additional_params overrides could be ignored; object values now merge and other values replace the baseline, with regression coverage.

The final independent review found no remaining P0/P1 issues or confirmed hook-parity, extractor/provider-compatibility, security, or raw-Agent bypass defects.

Validation

  • cargo fmt --all
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test
  • cargo test -p rig-core
  • cargo test -p rig --all-features --test gemini gemini::cassette::extractor -- --nocapture --test-threads=1
  • cargo test -p rig --all-features --test gemini gemini::cassette::agent_run -- --nocapture --test-threads=1
  • cargo doc --workspace --no-deps
  • git diff --check

Credential-dependent live tests remain ignored as designed. Workspace docs retain one unrelated pre-existing rig-neo4j private intra-doc-link warning.

@gold-silver-copper gold-silver-copper marked this pull request as ready for review July 16, 2026 05:53
…unner-execution

# Conflicts:
#	tests/providers/gemini/cassette/agent_run_streamed.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant