-
Notifications
You must be signed in to change notification settings - Fork 9
fix(agent): restart codex agents after config changes #430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -135,7 +135,11 @@ func (s *Service) UpdateAgentProfile(id string, profile AgentProfile) (AgentProf | |
| return AgentProfileView{}, err | ||
| } | ||
| s.mu.Unlock() | ||
| if restartRequired && runtimeRunning && !isGatewayRuntimeKind(runtimeKind) { | ||
| if restartRequired && runtimeRunning && strings.EqualFold(runtimeKind, RuntimeKindCodex) { | ||
| if _, err := s.restartCodexRuntime(context.Background(), id); err != nil { | ||
| return AgentProfileView{}, err | ||
| } | ||
| } else if restartRequired && runtimeRunning && !isGatewayRuntimeKind(runtimeKind) { | ||
| s.stopLifecycleAgent(id) | ||
| } | ||
| if err := s.syncGatewayAfterProfileChange(context.Background(), id, previous, normalized, restartRequired); err != nil { | ||
|
|
@@ -503,15 +507,19 @@ func (s *Service) update(ctx context.Context, id string, req UpdateRequest) (Age | |
| } | ||
| } | ||
| } | ||
| if restartRequired && runtimeRunning && !isGatewayRuntimeKind(runtimeKind) { | ||
| if restartRequired && runtimeRunning && strings.EqualFold(runtimeKind, RuntimeKindCodex) { | ||
| if _, err := s.restartCodexRuntime(ctx, id); err != nil { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This new restart path makes the existing Codex MCP API subtest terminate its own test process:
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 52def89. The API fixture now launches a dedicated test child process and tracks/stops it through the fake manager instead of using the package test PID. The exact Codex MCP subtest now passes, including with the race detector. |
||
| return Agent{}, err | ||
| } | ||
| } else if restartRequired && runtimeRunning && !isGatewayRuntimeKind(runtimeKind) { | ||
| s.stopLifecycleAgent(id) | ||
| } | ||
|
|
||
| updated, ok := s.Agent(id) | ||
| if !ok { | ||
| return Agent{}, fmt.Errorf("agent %q not found", id) | ||
| } | ||
| if mcpServersUpdated && restartRequired && runtimeRunning && isManagerAgent(updated) { | ||
| if mcpServersUpdated && restartRequired && runtimeRunning && isManagerAgent(updated) && updated.AgentProfile.EnvRestartRequired { | ||
| return s.Recreate(ctx, id) | ||
| } | ||
| if runtimeAffectingUpdate { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This restart enters
Runtime.Start, but that path still createsSessionSpecwithout reading the newconversation_sessionsfield.ensureSessionthen persists the restarted session with an empty map, so every automatic profile/MCP restart erases all room-to-thread mappings. I reproduced this withStop -> Start: the savedroom-1mapping was absent from the restart spec. Load the mapping in the normalStartpath and add a stop/start regression test.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 52def89. Runtime.Start now reads the persisted session metadata and passes ConversationSessions into the new SessionSpec. I also added a Stop -> Start regression test that verifies the room-to-thread mapping reaches the restarted session.