fix(session): preserve agent identity across headless resume - #925
fix(session): preserve agent identity across headless resume#925breedx wants to merge 4 commits into
Conversation
…nflicting initialization
|
The new resume regressions pass in upstream CI, but the full suite hits an existing midnight-sensitive session-browser assertion. I reproduced the same failure on unpatched
The CI test environment is Python 3.14.7 despite its 3.13 label; local controls were Python 3.13.13. Deprecation/resource/coroutine warnings were inspected, but not all CI warnings have independent base controls. The full suite is not claimed green. #926 remains a dependent draft awaiting #925 acceptance and subsequent requalification. |
|
Superseded by the combined resume proposal #926, which already contains every identity commit from this PR along with structural prompt persistence. Keeping one review and landing target for the complete user-facing behavior. All commits are preserved; this closure is not a merge and does not discard the identity implementation. Please continue review on #926. |
Resuming a conversation in a fresh process currently gives the agent a new identity, even when its message history is restored. Persist identity with that history so headless runners and CLI resume continue the same agent, and reject conflicting explicit identities instead of silently switching ownership.
Related upstream work
set_message_historyresume path—not identity recovery from rendered prompt text or a single frontend.BaseAgent.idacross persisted histories; it does not equate that ID with every hook run/session ID or implement hook propagation.Change
ModelRequest.metadata, preserving unrelated metadata.set_message_history; a saved ID wins over a randomly generated process default, while a conflicting explicitly initialized ID fails before replacing active history./quick-resumeand/load_contexterror boundaries. The existing interactive picker error boundary is exercised too.The small
command_line/session_commands.pychange corrects existing load-error handling rather than adding a command. Given the plugin-first guidance, please flag a preferred supported seam before landing if this should be routed differently; the common history restore remains the authoritative identity boundary.Validation
Base
ce1fe372(0.0.827), Linux / Python 3.13.13, unchanged upstream dependency lock in a dedicated environment. Tests use disposable HOME/XDG and no inherited credentials; socket connect/DNS/bind is blocked, including in subprocess fixtures.test_open_project_and_select_sessionassertion requiringTODAY: the fixture subtracts one/two hours from the wall clock, so immediately after midnight both entries are correctly labeled yesterday. The exact failure reproduces on unpatched upstream. No tests were skipped or rewritten to hide it.Two stream-callback coroutine warnings and the CLI test's unawaited
maincoroutine reproduce on base. Quick-resume still invokes the existing deprecated autosave setter; this patch does not suppress its warning. This is scoped evidence, not a green full-suite or live-provider claim.Compatibility and boundaries
Existing metadata-free histories keep the current/default identity on first restore; after the next checkpoint, the identity is persisted. This deliberately does not infer an old identity from prose. It does not change session file names, formats, migration policy, retry custody, hooks, MCP behavior, dependencies or package versions. New metadata travels with the existing message-history serialization. No prompt-caching or measured cost-saving claim is made by the identity patch alone.