Repository navigation
fix(daemon): count a claimed agent resume as automatic even without a history seed - #27442
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 7 minutes. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to An authenticated client can submit an agent-session claim it does not own, and the host now counts an unseeded request as automatic. This can consume capacity needed by legitimate agent resumes; bind claims to their producer or explicitly accept the bounded admission risk before merging. Pre-merge checks |
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
aed39e7f-79f1-4bdc-be32-4db736539cfc
📒 Files selected for processing (3)
src/main/daemon/terminal-spawn-gate.test.tssrc/shared/host-spawn-admission.test.tssrc/shared/host-spawn-admission.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
| // Why a claim alone: a remote client's `--resume` arrives on a fresh terminal id with no | ||
| // history seed, so requiring one let every reconnect storm through. An old caller is only | ||
| // ever paced, so a user-started agent costs at most a short wait during a storm. | ||
| const intent = | ||
| facts.declaredIntent ?? | ||
| (facts.hasAgentSessionClaim && facts.hasHistorySeed ? 'automatic-restore' : 'interactive') | ||
| facts.declaredIntent ?? (facts.hasAgentSessionClaim ? 'automatic-restore' : 'interactive') |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
set -eu
printf '%s\n' '--- changed diff ---'
git diff --unified=35 b53ba14fd36bc79adebc9c9058379628b5b156b5 f9c00ed9bbb81a153a151c81e592954f7559d001 -- src/shared/host-spawn-admission.ts
printf '%s\n' '--- claim admission ---'
nl -ba src/main/daemon/daemon-terminal-admission.ts | sed -n '55,105p'
printf '%s\n' '--- claim handler ---'
nl -ba src/main/daemon/terminal-host-agent-session-claim.ts | sed -n '1,80p'
printf '%s\n' '--- session create ---'
nl -ba src/main/daemon/terminal-host-session-create.ts | sed -n '95,160p'
printf '%s\n' '--- owner registry ---'
nl -ba src/shared/claimed-agent-pty-owner.ts | sed -n '100,185p'
printf '%s\n' '--- spawn accounting ---'
nl -ba src/main/daemon/terminal-spawn-gate.ts | sed -n '35,115p'Repository: stablyai/orca
Length of output: 18191
Validate claim ownership before inferring automatic-restore.
An authenticated client can submit a structurally valid agentSessionEnsure claim without producer-ownership validation. terminal-host-session-create.ts then sets hasAgentSessionClaim even when launchAgent is absent. The changed inference classifies that non-agent PTY as automatic-restore; the claim path also creates an agent owner record, and a live PTY increments liveAutomatic.
Keep fresh-terminal, no-history resumes eligible for automatic restore, but only after the daemon validates that the claim belongs to the authenticated agent session. The observe-only gate prevents pacing or admission changes, but it does not prevent incorrect owner state or live-session accounting.
f9c00ed to
b8f0872
Compare
b8f0872 to
c8d3b01
Compare
ELI5
The terminal host decides whether a request is an "automatic restore", which gets paced, or something a person just did, which never waits. For clients that do not say which it is, the host guessed "automatic restore" only when the request carried both an agent identity and saved scrollback. A phone or another computer reconnecting to
orca serveresumes its agents in brand-new terminals with no saved scrollback, so the guess never matched, and a reconnect storm went straight through. Now an agent identity alone is enough.What Changed
--resumelaunches (ensureAgentSession/ agent creates from paired clients) arrive on fresh terminal ids with no seed, so they were charged as interactive. They were never paced on a headless host.Why
On headless hosts (#27428), pacing is the protection that applies to every client that has not declared an intent yet. That is all clients today. Without this change it covered only restores made on the host itself, not the reconnect storms from paired clients that #10493 describes. Callers that have not declared an intent are only ever paced, never deferred or refused (except at critical pressure after their admission window). Misclassifying a user who starts an agent therefore costs at most a short wait while a storm is running: a burst of 3 is admitted immediately, then 1 per second. The full fix is clients declaring their intent; that comes in the client PR.
Linked Issue
Refs #10493
Visual Proof
N/A: no UI. On a headless host, agent resumes from a reconnecting client now start a few at a time.
Testing
host-spawn-admission.test.ts: a claim without a seed is inferred as automatic. No claim is interactive.terminal-spawn-gate.test.ts: a claimed create with no history seed is counted as a live automatic session.pnpm tc,pnpm lint,pnpm run check:code-quality:changedand the terminal-host suites pass.Review
Agent skill upstream boundary
Notes
Checklist
N/Afor visuals with reasonpnpm lint,pnpm typecheck, and focused tests pass locally; CI covers the rest