Skip to content

Add autonomous finish contract - #223

Closed
sethkarten wants to merge 1 commit into
feature/autonomous-user-simfrom
feature/autonomous-finish-contract
Closed

Add autonomous finish contract#223
sethkarten wants to merge 1 commit into
feature/autonomous-user-simfrom
feature/autonomous-finish-contract

Conversation

@sethkarten

@sethkarten sethkarten commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add an autonomous finish contract that prevents stopping with only "I think it works"
  • require evidence before autonomous mode stops: git patch, passing test/check evidence, blocker artifact, or justified no-op
  • feed a host-side continuation prompt when the finish contract is not satisfied
  • keep the feature scoped to autonomous mode and leave normal sessions unchanged

Testing

  • npm --prefix packages/coding-agent test -- suite/agent-session-autonomous.test.ts
  • ./node_modules/.bin/tsgo --noEmit
  • npm run check
  • stacked autonomous suite on feature/autonomous-quality-gates: npm --prefix packages/coding-agent test -- suite/agent-session-autonomous.test.ts args.test.ts

Note

Add autonomous finish contract to require evidence before stopping autonomous agent sessions

  • Introduces a finishContract concept in autonomous.ts: when enabled (default), the agent checks for concrete finish evidence before accepting a stop decision.
  • Evidence is detected via 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.
  • If evidence is missing, shouldAutonomouslyContinue returns a new 'finish_contract' decision reason, and nextAutonomousContinuation injects a specific prompt (DEFAULT_AUTONOMOUS_FINISH_PROMPT) demanding concrete evidence.
  • AgentSession._getContinuationMessages now passes { cwd } to nextAutonomousContinuation so git status checks use the correct working directory.
  • Behavioral Change: autonomous sessions enabled by default will no longer stop unless the agent produces a git patch, passes tests, references a blocker, or explicitly justifies a no-op.

Macroscope summarized 9f03440.

@sethkarten

Copy link
Copy Markdown
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.

@sethkarten sethkarten closed this Jun 23, 2026
@kevinjosethomas
kevinjosethomas deleted the feature/autonomous-finish-contract branch June 26, 2026 00:37
@kevinjosethomas
kevinjosethomas restored the feature/autonomous-finish-contract branch June 26, 2026 00:37
@kevinjosethomas
kevinjosethomas deleted the feature/autonomous-finish-contract branch July 8, 2026 00:29
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
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