Make AgentRunner the only Agent execution path#2161
Open
gold-silver-copper wants to merge 4 commits into
Open
Conversation
…unner-execution # Conflicts: # tests/providers/gemini/cassette/agent_run_streamed.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AgentRunnerthe only execution path for configuredAgentinstancesCompletionandStreamingCompletiontraits and their Agent implementationsCompletionModelExtractorthrough the full hook lifecycle while preserving retry, usage, schema, and provider request behaviorAgentRunexamples/tests to explicitly raw sans-I/O provider workflowsWhy
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
AgentRunexamples 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 aCompletionModeldirectly.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::newdiscarded the Agent's configured hooks; it now preserves them, with a regression proving a terminating Agent hook prevents provider I/O.additional_paramsoverrides 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 --allcargo clippy --all-targets --all-features -- -D warningscargo testcargo test -p rig-corecargo test -p rig --all-features --test gemini gemini::cassette::extractor -- --nocapture --test-threads=1cargo test -p rig --all-features --test gemini gemini::cassette::agent_run -- --nocapture --test-threads=1cargo doc --workspace --no-depsgit diff --checkCredential-dependent live tests remain ignored as designed. Workspace docs retain one unrelated pre-existing
rig-neo4jprivate intra-doc-link warning.