Repository navigation
fix(ui): drop a withheld file's approved flag when its session rebuilds - #8398
Conversation
…ebuilt The relayed session panel kept listing a file as approved after the agent that held the approval was gone, because _approved_paths in session_environment.py was only cleared by forget_session on chat delete, never on eviction or a sidecar restart. The sidecar now flags session_created on a turn's terminal event whenever it built a fresh agent for that session_id -- eviction, restart, or first use, not just the already-flagged eviction case. The relay drops the chat's approved-paths cache whenever it sees that flag, regardless of how the turn ended. Closes amd#8083
|
Verdict: Request changes This PR makes the Agent UI forget files a chat approved whenever the gaia sidecar rebuilds that chat's agent, which is the right idea for #8083. As written, though, it clears the list at the end of the turn, so it also wipes approvals the user made during that turn.
Real-world evidenceN/A: no evidence bundle was produced for this run. The verdict rests on static review. The session panel and the sidecar restart/eviction paths weren't exercised live, and the PR's own Evidence section marks the Agent UI as N/A. 🔍 Technical detailsIssues 🔴 Mid-turn approvals are erased on every freshly built turn (
The sidecar's agent keeps the grant for the rest of the session, but the panel no longer lists it. The same thing happens on the first turn after a restart or eviction, which is the exact case this PR targets. The new tests miss this because they call
Either way, add a test that records an approval mid-turn on a 🟡 New SSE field with no contract bump or docs (
🟢 First use is indistinguishable from a rebuild. Even after the 🔴 fix, a brand-new chat always triggers Strengths
|
…rase The previous commit cleared a chat's whole approved-paths cache whenever session_created arrived, which also wiped out an approval the user made during that very turn: note_approved_path runs mid-turn, forget_session ran at the end, and the two raced on the same turn every time a session was rebuilt -- including the common case of a chat's very first turn. Snapshot the chat's approved paths when the turn starts (relay_query already has the session_id) and, on session_created, drop only what was in that snapshot. Anything approved during the same turn is approved after the snapshot, so it survives. Bumps the sidecar contract to 2.31 and documents session_created on final/error in the SPEC, SKILL.md and CHANGELOG, which the first commit left undocumented. Addresses review feedback on amd#8398.
|
Good catch on the mid-turn erasure — you're right, that was a real regression and on the common path too. Pushed a fix: Also bumped the contract to 2.31 and documented |
|
Verdict: Request changes Both earlier findings are fixed: approvals made during a rebuilt turn now survive, and 🟡 After a restart or eviction, approving the same file again still wipes it from the panel. The new agent has lost its grant, so it asks again for a file the chat already approved. The user approves it, but the chat's list already holds that path, so nothing new is recorded. The end-of-turn snapshot diff then treats it as stale and drops it. The agent can open the file and the panel doesn't list it. This is probably the most common restart case, because users tend to go back to the file they were working on. Track what this turn approved separately from the start-of-turn list. 🔍 Technical details
Possible fix: record this turn's approvals in their own per-session set. Clear it when |
|
Verdict: Request changes The latest push only merges 🟡 If the user approves the same file again after a restart or eviction, it still drops off the panel. The rebuilt agent asks again for a file the chat already approved. The user approves it, but the path is already in the chat's list, so nothing new gets recorded. When the turn ends, the snapshot diff treats the path as stale and removes it. The agent can still open the file, but the panel no longer shows it. Track this turn's approvals separately from the list taken at the start of the turn. 🔍 Technical details
|
|
I merged current 🔍 Technical details
|
|
Verdict: Request changes This push only merges 🟡 If the user approves the same file again after a restart or eviction, it still drops off the panel. The rebuilt agent asks for a file the chat already approved. The user approves it, but the path is already in the list, so nothing new is recorded. When the turn ends, the cleanup treats the path as stale and removes it. The agent can still open the file, but the panel no longer shows it. Track each turn's approvals apart from the list taken when the turn starts. 🔍 Technical details
|
…the sidecar The sidecar now reports contract 2.31 for session_created, but the npm package still declared 2.30, so its contract-constants test failed.
|
Thanks @iam-hk — the panel finally tells the truth after a sidecar restart, and spotting that the eviction flag could never fire across a fresh process was a sharp catch. I'll pick up the re-approval edge case in a small follow-up so this didn't have to wait. |
…8816) After a sidecar restart or eviction, the rebuilt agent asks again for a file the chat had already approved. Approving it again made the file disappear from "Files GAIA can reach", even though the agent could still open it. Now a file approved again during the rebuilt turn stays listed; files nobody re-approved are still dropped. Follow-up to #8398 (the last open review point there); refs #8083. ## Test plan - [x] `python -m pytest tests/unit/test_sidecar_relay_fidelity.py`: the re-approval tests fail without the fix and pass with it - [x] `python -m pytest tests/unit/test_sidecar_relay.py hub/agents/gaia/python/tests/test_session_registry.py` passes - [x] `python util/lint.py --black --isort --flake8` passes
Summary
The relayed session panel ("Files GAIA can reach") kept listing a file as approved after the agent session that held that approval was gone — eviction, a sidecar restart, or just the chat's underlying session being rebuilt.
Why
_approved_pathsinsrc/gaia/ui/session_environment.pyis only cleared byforget_session, which is only called from the chat-delete path inrouters/sessions.py. It is never cleared on eviction or a sidecar restart, so a file approved at a prompt kept showing as reachable even after the agent instance that actually held the grant no longer existed.The existing
reclaimed_after_evictionflag on_AgentSessiononly fires when the in-memorySessionRegistry._evicted_idsrecognizes the session_id as a previous eviction — which a sidecar restart (a fresh process, so that dict is empty) can never satisfy, even though a brand-new agent was just built for a session_id the UI still thinks is live.Linked issue
Closes #8083
Changes
hub/agents/gaia/python/gaia_agent/session_registry.py: newfreshly_builtflag on_AgentSession, true on every path that constructs a fresh agent for a session_id (eviction-reclaim, restart, or first use) — not just the already-covered eviction case.hub/agents/gaia/python/gaia_agent/server.py: the/queryhandler consumesfreshly_builtonce per turn and merges asession_created: truefield onto the turn's terminal SSE event (finalorerror), regardless of how the turn ended.src/gaia/ui/email_sidecar/relay.py:_dispatch_onetakes the chat'ssession_idand, on seeingsession_created, callssession_environment.forget_session(session_id)to drop the chat's stale approved-paths cache.hub/agents/gaia/python/tests/test_session_registry.pyandtests/unit/test_sidecar_relay_fidelity.py.Test plan
pytest hub/agents/gaia/python/tests/test_session_registry.py -v— 28 passed, including 3 new tests forfreshly_built(first use, eviction-reclaim, consume-once).pytest tests/unit/test_sidecar_relay_fidelity.py -v— 83 passed, including 3 new tests for the relay'ssession_createdhandling (final, no-flag, error terminal).pytest hub/agents/gaia/python/tests/(full package) — 1548 passed; the 6 failures/errors present are pre-existing in this sandbox (missingghCLI, insufficient memory to load a local model, and one unrelated tool-registry name drift) and reproduce identically onmainwith the same install.python util/lint.py --allon the changed files: black, isort, flake8 all clean. The pylint run reports 23 pre-existing errors, none in any file this PR touches.Evidence
_dispatch_onedropping the chat's approved-paths cache onsession_created./querySSE contract gains one additional field (session_created) on its terminal event; covered by the server-side test suite, not a new endpoint.Checklist
Closes #8083).