Compare commits

...

2 Commits

Author SHA1 Message Date
Peter Steinberger
e7aeb7c3e9 test: cover text-mode CLI session IDs (#52712) (thanks @kenantan32) 2026-03-26 23:33:54 +00:00
kenantan32
7c8d75e3d6 fix: preserve CLI session ID in text output mode
When the CLI backend output mode is "text", sessionId was hardcoded to
undefined. This caused the fallback chain to store the OpenClaw internal
UUID as the CLI session ID. On resume, --resume was called with the
wrong UUID, resulting in "No conversation found with session ID".

Return resolvedSessionId instead of undefined so the correct CLI session
ID is persisted and resume works correctly.
2026-03-26 23:30:41 +00:00
3 changed files with 39 additions and 1 deletions

View File

@@ -62,6 +62,8 @@ Docs: https://docs.openclaw.ai
- Agents/failover: classify Codex accountId token extraction failures as auth errors so model fallback continues to the next configured candidate. (#55206) Thanks @cosmicnet.
- Talk/macOS: stop direct system-voice failures from replaying system speech, use app-locale fallback for shared watchdog timing, and add regression coverage for the macOS fallback route and language-aware timeout policy. (#53511) thanks @hongsw.
- Discord/gateway cleanup: keep late Carbon reconnect-exhausted errors suppressed through startup/dispose cleanup so Discord monitor shutdown no longer crashes on late gateway close events. (#55373) Thanks @Takhoffman.
- CLI/agents: stop injecting a fake "Tools are disabled" system-prompt line into CLI backend runs, so Claude CLI native tools can decide tool usage themselves. (#46214) Thanks @Dhi13man.
- CLI/agents: preserve backend session IDs for text-output CLI runs so resume uses the real CLI session handle instead of the OpenClaw session UUID. (#52712) Thanks @kenantan32.
## 2026.3.24

View File

@@ -316,6 +316,42 @@ describe("runCliAgent with process supervisor", () => {
expect(input.scopeKey).toContain("thread-123");
});
it("preserves the existing CLI session ID for text output mode", async () => {
supervisorSpawnMock.mockResolvedValueOnce(
createManagedRun({
reason: "exit",
exitCode: 0,
exitSignal: null,
durationMs: 50,
stdout: "ok",
stderr: "",
timedOut: false,
noOutputTimedOut: false,
}),
);
const result = await runCliAgent({
sessionId: "s1",
sessionFile: "/tmp/session.jsonl",
workspaceDir: "/tmp",
config: EXISTING_CODEX_CONFIG,
prompt: "hi",
provider: "codex-cli",
model: "gpt-5.4",
timeoutMs: 1_000,
runId: "run-text-session-id",
cliSessionBinding: {
sessionId: "thread-123",
authProfileId: "openai-codex:default",
},
authProfileId: "openai-codex:default",
});
expect(result.payloads?.[0]?.text).toBe("ok");
expect(result.meta.agentMeta?.sessionId).toBe("thread-123");
expect(result.meta.agentMeta?.cliSessionBinding?.sessionId).toBe("thread-123");
});
it("keeps resuming the CLI across model changes and passes the new model flag", async () => {
mockSuccessfulCliRun();

View File

@@ -422,7 +422,7 @@ export async function runCliAgent(params: {
const outputMode = useResume ? (backend.resumeOutput ?? backend.output) : backend.output;
if (outputMode === "text") {
return { text: stdout, sessionId: undefined };
return { text: stdout, sessionId: resolvedSessionId };
}
if (outputMode === "jsonl") {
const parsed = parseCliJsonl(stdout, backend);