Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions internal/engine/lost_cli_session_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package engine

import (
"errors"
"testing"
)

// TestLostCLISession covers the phrasings the CLIs print when the session a
// node wants to resume no longer exists on the execution machine. Every one of
// them must drop the stored session and restart the node, not park it on a
// human gate.
func TestLostCLISession(t *testing.T) {
lost := []string{
"no conversation found",
"Session not found",
"no such session",
"conversation does not exist",
// Codex JSON-RPC reply after the sandbox recreated .agentflow.
"Error: thread/resume: thread/resume failed: no rollout found for thread id 01a1f321-9110-7af0-8a19-2b32b06025d4 (code -32600)",
"thread/resume failed",
"code -32600",
}
for _, msg := range lost {
if !lostCLISession(msg, nil) {
t.Errorf("lostCLISession(%q) = false, want true", msg)
}
if !lostCLISession("", errors.New(msg)) {
t.Errorf("lostCLISession(err=%q) = false, want true", msg)
}
}
for _, msg := range []string{
"",
"unexpected status 503 Service Unavailable",
"exit status 1",
"REJECT: 独立评审未通过",
} {
if lostCLISession(msg, nil) {
t.Errorf("lostCLISession(%q) = true, want false", msg)
}
}
}
10 changes: 9 additions & 1 deletion internal/engine/node_execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,15 @@ func lostCLISession(output string, err error) bool {
return strings.Contains(msg, "no conversation found") ||
strings.Contains(msg, "session not found") ||
strings.Contains(msg, "no such session") ||
strings.Contains(msg, "conversation does not exist")
strings.Contains(msg, "conversation does not exist") ||
// Codex answers `exec resume <id>` with a JSON-RPC error when the
// thread's rollout file is gone, which happens when the sandbox is
// recreated or re-prepared and .agentflow is reset. The session is
// equally unrecoverable, so the node must restart instead of parking
// on a human gate.
strings.Contains(msg, "no rollout found") ||
strings.Contains(msg, "thread/resume failed") ||
strings.Contains(msg, "code -32600")
}

func clipHumanGateDetail(detail string) string {
Expand Down