Add autonomous finish contract - #223
Closed
sethkarten wants to merge 1 commit into
Closed
Conversation
Contributor
Author
|
Closing as superseded by #222. The finish-contract behavior is now implemented there as host-side terminal-evidence checks instead of a separate PR. |
zhengr
pushed a commit
to zhengr/prime-agent
that referenced
this pull request
Aug 8, 2026
…ai#223) Add getApiKey hook to AgentLoopConfig that resolves API keys dynamically before each LLM call. This allows short-lived OAuth tokens (e.g. GitHub Copilot, Anthropic OAuth) to be refreshed between turns when tool execution takes a long time. Previously, the API key was resolved once when ProviderTransport.run() was called and passed as a static string to the agent loop. If the loop ran for longer than the token lifetime (e.g. 30 minutes for Copilot), subsequent LLM calls would fail with expired token errors. Changes: - Add getApiKey hook to AgentLoopConfig (packages/ai) - Call getApiKey before each LLM call in streamAssistantResponse - Update ProviderTransport to pass getApiKey instead of static apiKey - Update web-ui ProviderTransport with same pattern
zhengr
pushed a commit
to zhengr/prime-agent
that referenced
this pull request
Aug 8, 2026
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
Testing
npm --prefix packages/coding-agent test -- suite/agent-session-autonomous.test.ts./node_modules/.bin/tsgo --noEmitnpm run checkfeature/autonomous-quality-gates:npm --prefix packages/coding-agent test -- suite/agent-session-autonomous.test.ts args.test.tsNote
Add autonomous finish contract to require evidence before stopping autonomous agent sessions
finishContractconcept in autonomous.ts: when enabled (default), the agent checks for concrete finish evidence before accepting a stop decision.hasAutonomousFinishEvidence, which checks for pending git worktree changes (git status --porcelain) or text patterns indicating passing tests, a blocker artifact, or a justified no-op.shouldAutonomouslyContinuereturns a new'finish_contract'decision reason, andnextAutonomousContinuationinjects a specific prompt (DEFAULT_AUTONOMOUS_FINISH_PROMPT) demanding concrete evidence.AgentSession._getContinuationMessagesnow passes{ cwd }tonextAutonomousContinuationso git status checks use the correct working directory.Macroscope summarized 9f03440.