Repository navigation
fix(agent-console): preserve Devin start name and refresh delayed session preview #398
Description
Summary
Starting an interactive Devin agent from agent console with a custom name can produce two related failures:
- The agent is permanently stored and displayed as
ai-devkit-<pid>instead of the requested name. - The live session preview remains unavailable even after chatting with Devin; restarting the console makes the conversation appear, but the generated name remains.
The process starts successfully. The failure is a race between daemon discovery, managed-start registry persistence, and Devin's delayed session creation.
Reproduction
- Open
ai-devkit agent consolewith the daemon enabled. - Open the start-agent pane.
- Choose Devin, enter a custom name, and submit.
- Chat with the new Devin agent.
- Observe the agent list and preview.
- Stop and reopen the console.
Actual behavior
- Immediately after start, the list shows
ai-devkit-<pid>, not the submitted name. - The preview reports no session/conversation while the console remains open.
- After restarting the console, the preview contains the existing conversation, but the name is still
ai-devkit-<pid>. agent detailafter restart returns the full Devin conversation, confirming that the session data itself is valid.
Expected behavior
- The requested name is authoritative for a successfully managed start and persists across refreshes/restarts.
- Once Devin creates its session and conversation rows, the open console discovers the session and renders preview messages without requiring a restart.
Confirmed timing
In the reproduced run:
- The daemon first observed the Devin process and the registry fallback row was created at effectively the same instant.
- The fallback row used
ai-devkit-<pid>with no session id/path. - Devin's session row and lock appeared about 13 seconds later.
- A later fresh list populated the session id/path and made four existing conversation messages readable, while the generated name remained persisted.
Root cause 1: requested name loses to daemon fallback registration
The console starts an agent through a child CLI process. As soon as the Devin process appears, the daemon emits agent.appeared, causing the parent console to refresh before the child agent start command finishes registration.
That refresh registers the daemon's generated ai-devkit-<pid> identity first. When managed start later calls AgentRegistry.register() with the requested name, mergeEntry() unconditionally preserves existing.name. The generated fallback therefore wins over the explicit managed-start name and remains in agents.db.
Relevant paths:
packages/cli/src/tui/console/hooks/useStartAgentPane.tspackages/agent-manager/src/runtime/ManagedAgentRuntime.tspackages/agent-manager/src/AgentManager.tspackages/agent-manager/src/utils/AgentRegistry.ts
Root cause 2: delayed Devin attribution does not refresh the subscribed console
The initial daemon event describes a process-only Devin agent because the Devin session DB row/lock does not exist yet. The daemon enriches its cache on later sweeps, but it only emits lifecycle events for appeared/disappeared PIDs—not when an existing PID gains sessionId or sessionFilePath.
After a daemon subscription succeeds, useAgentList relaxes normal polling to a 60-second fallback. The immediate post-start refresh() also occurs before Devin creates the session (and can be dropped if another refresh is already in flight). useAgentConversation therefore keeps receiving an agent object without sessionFilePath and cannot read the conversation. Restarting the console forces a fresh list and resolves the session.
Relevant paths:
rust/crates/devkitd/src/server.rspackages/cli/src/tui/console/hooks/useAgentList.tspackages/cli/src/tui/console/hooks/useAgentConversation.tspackages/agent-manager/src/harnesses/devin/DevinAdapter.ts
Suggested direction
Preserve the managed name
Add an authoritative managed-start registration/claim operation keyed by (type, pid) that may replace a known generated fallback name, while still preserving genuine user renames. Alternatively, reserve the requested name before process discovery and bind it to the PID after launch.
Regression coverage should reproduce this order:
- discovery registers
ai-devkit-<pid>; - managed start registers the requested name for the same type/PID;
- the final row and returned list use the requested name.
Refresh delayed session attribution
Emit an update event when an existing process gains or changes enriched session identity/path, or temporarily fast-poll the newly started agent until its session attribution is available. Manual refresh requests should also coalesce behind an in-flight refresh rather than being silently discarded.
Regression coverage should model a Devin process appearing first and its session row/lock appearing later, then verify that the already-open console receives the session path and preview without remounting.
Environment
- AI DevKit 0.70.1
- macOS ARM64
- Interactive Devin agent started from
agent console - Daemon subscription enabled
Related
- fix(cli): refresh agent console list after rename #374 concerns rename UI refresh after an explicit rename. This issue is different: the requested name is lost during managed start, before any rename action.
Activity