Skip to content

Commit c6134e4

Browse files
Merge branch 'main' into fix/issue-83902
2 parents d726709 + 448eb36 commit c6134e4

23 files changed

Lines changed: 762 additions & 106 deletions

‎CHANGELOG.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Docs: https://docs.openclaw.ai
1111

1212
### Fixes
1313

14+
- Agents/messages: stop message-tool-only turns after a successful source-channel `message` send while keeping transcript mirrors under the session write lock. (#84289)
1415
- Agents: filter silent heartbeat response-tool transcript artifacts out of embedded context snapshots so later user turns are not polluted by heartbeat no-op messages. (#83477) Thanks @fuller-stack-dev.
1516
- Agents/OpenAI: log repeated strict tool-schema downgrade diagnostics once per provider/model/tool signature, reducing duplicate debug noise while preserving `strict=false` fallback behavior. Fixes #82930. (#82933) Thanks @galiniliev.
1617
- Agents/code mode: spell out the `exec` tool's JavaScript/TypeScript, no Node module, and catalog-bridge constraints in model-visible schema text so agents can use enabled tools without trial-and-error. (#84269) Thanks @Kaspre.
@@ -31,7 +32,6 @@ Docs: https://docs.openclaw.ai
3132
- Docker: keep the bundled Codex plugin in official release image keep lists so the default OpenAI agent harness remains available after Docker pruning. Fixes #83613. (#83626) Thanks @YuanHanzhong.
3233
- CLI/channels: preserve the first line of `openclaw channels logs` output when the rolling tail window starts exactly on a line boundary, mirroring the already-fixed `readLogSlice` behavior in `src/logging/log-tail.ts`.
3334
- Control UI: treat terminal session status as authoritative over stale active-run flags so completed terminal runs stop showing abort/live UI. (#84057)
34-
- Codex/message: tell message-tool-only Codex turns to send visible channel output with `message(action="send")` before ending, so direct replies do not stay private. Fixes #84129. (#84397) Thanks @joshavant.
3535
- CLI: preserve embedded equals signs in inline root option values instead of truncating after the second separator. (#83995) Thanks @ThiagoCAltoe.
3636
- Matrix/config: accept `messages.queue.byChannel.matrix` queue overrides and keep queue provider schema/type keys aligned for Matrix, Google Chat, and Mattermost. Thanks @bdjben.
3737
- CLI: format `openclaw acp client` failures through the shared error formatter so object-shaped errors stay readable instead of printing `[object Object]`. Fixes #83904. (#84080)

‎extensions/codex/src/app-server/run-attempt.test.ts‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,12 +1402,7 @@ describe("runCodexAppServerAttempt", () => {
14021402
testing.buildDeveloperInstructions(params, {
14031403
dynamicTools: [createMessageDynamicTool("Message test tool")],
14041404
}),
1405-
).toContain('call `message` with `action="send"` before ending the turn');
1406-
expect(
1407-
testing.buildDeveloperInstructions(params, {
1408-
dynamicTools: [createMessageDynamicTool("Message test tool")],
1409-
}),
1410-
).toContain("Do not rely on normal final assistant text for visible delivery");
1405+
).toContain("To send a visible message, use the `message` tool.");
14111406

14121407
const withoutMessageToolInstructions = testing.buildDeveloperInstructions(params, {
14131408
dynamicTools: [],
@@ -1418,7 +1413,7 @@ describe("runCodexAppServerAttempt", () => {
14181413
params.sourceReplyDeliveryMode = "automatic";
14191414
const automaticInstructions = testing.buildDeveloperInstructions(params);
14201415
expect(automaticInstructions).toContain("active Codex delivery path");
1421-
expect(automaticInstructions).not.toContain('call `message` with `action="send"`');
1416+
expect(automaticInstructions).not.toContain("use the `message` tool");
14221417
});
14231418

14241419
it("includes Codex app-server scoped plugin command guidance in developer instructions", () => {

‎extensions/codex/src/app-server/thread-lifecycle.ts‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -884,12 +884,7 @@ function buildVisibleReplyInstruction(
884884
? dynamicTools.some((tool) => tool.name.trim() === "message")
885885
: params.disableMessageTool !== true;
886886
if (params.sourceReplyDeliveryMode === "message_tool_only" && messageToolAvailable) {
887-
return [
888-
"Preserve channel/session context.",
889-
'If this turn needs visible output in the current channel, call `message` with `action="send"` before ending the turn.',
890-
"Do not rely on normal final assistant text for visible delivery; final text is private to OpenClaw/Codex in this mode.",
891-
'If no visible channel response is needed, do not call `message(action="send")`.',
892-
].join(" ");
887+
return "To send a visible message, use the `message` tool.";
893888
}
894889
return "To send a visible reply, use the active Codex delivery path.";
895890
}

‎src/agents/pi-embedded-runner/run/attempt.session-lock.test.ts‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import fs from "node:fs/promises";
22
import os from "node:os";
33
import path from "node:path";
44
import { afterEach, describe, expect, it, vi } from "vitest";
5+
import {
6+
runWithOwnedSessionTranscriptWriteLock,
7+
withOwnedSessionTranscriptWrites,
8+
} from "../../../config/sessions/transcript-write-context.js";
59
import { SessionWriteLockTimeoutError } from "../../session-write-lock-error.js";
610
import {
711
createEmbeddedAttemptSessionLockController,
@@ -179,6 +183,37 @@ describe("embedded attempt session lock lifecycle", () => {
179183
expect(release).toHaveBeenCalledTimes(2);
180184
});
181185

186+
it("refreshes the prompt fence after an owned transcript mirror append", async () => {
187+
const sessionFile = await createTempSessionFile();
188+
const release = vi.fn(async () => {});
189+
const acquireSessionWriteLock = vi.fn(async () => ({ release }));
190+
const controller = await createEmbeddedAttemptSessionLockController({
191+
acquireSessionWriteLock,
192+
lockOptions: { ...lockOptions, sessionFile },
193+
});
194+
195+
await controller.releaseForPrompt();
196+
await withOwnedSessionTranscriptWrites(
197+
{
198+
sessionFile,
199+
sessionKey: "agent:main:discord:channel:123",
200+
withSessionWriteLock: (operation) => controller.withSessionWriteLock(operation),
201+
},
202+
async () =>
203+
await runWithOwnedSessionTranscriptWriteLock(
204+
{ sessionFile, sessionKey: "agent:main:discord:channel:123" },
205+
async () => {
206+
await fs.appendFile(sessionFile, '{"type":"message","id":"delivery-mirror"}\n', "utf8");
207+
},
208+
),
209+
);
210+
await expect(controller.withSessionWriteLock(() => "finalize")).resolves.toBe("finalize");
211+
212+
expect(controller.hasSessionTakeover()).toBe(false);
213+
expect(acquireSessionWriteLock).toHaveBeenCalledTimes(3);
214+
expect(release).toHaveBeenCalledTimes(3);
215+
});
216+
182217
it("returns a no-op cleanup lock after prompt lock reacquisition times out", async () => {
183218
const releases: string[] = [];
184219
const acquireSessionWriteLock = vi

‎src/agents/pi-embedded-runner/run/attempt.ts‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
runQuotaSuspensionMaintenance,
1616
updateSessionStoreEntry,
1717
} from "../../../config/sessions/store.js";
18+
import { withOwnedSessionTranscriptWrites } from "../../../config/sessions/transcript-write-context.js";
1819
import { resolveContextEngineOwnerPluginId } from "../../../context-engine/registry.js";
1920
import type { AssembleResult } from "../../../context-engine/types.js";
2021
import { emitTrustedDiagnosticEvent } from "../../../infra/diagnostic-events.js";
@@ -380,6 +381,7 @@ import {
380381
} from "./incomplete-turn.js";
381382
import { resolveLlmIdleTimeoutMs, streamWithIdleTimeout } from "./llm-idle-timeout.js";
382383
import { resolveMessageMergeStrategy } from "./message-merge-strategy.js";
384+
import { installMessageToolOnlyTerminalHook } from "./message-tool-terminal.js";
383385
import {
384386
MID_TURN_PRECHECK_ERROR_MESSAGE,
385387
isMidTurnPrecheckSignal,
@@ -2386,6 +2388,10 @@ export async function runEmbeddedAttempt(
23862388
session: activeSession,
23872389
withSessionWriteLock: (operation) => sessionLockController.withSessionWriteLock(operation),
23882390
});
2391+
installMessageToolOnlyTerminalHook({
2392+
agent: activeSession.agent,
2393+
sourceReplyDeliveryMode: params.sourceReplyDeliveryMode,
2394+
});
23892395
prepStages.mark("agent-session");
23902396
if (isRawModelRun) {
23912397
// Raw model probes should measure exactly the requested prompt against
@@ -3171,7 +3177,15 @@ export async function runEmbeddedAttempt(
31713177
prompt: string,
31723178
options?: Parameters<typeof activeSession.prompt>[1],
31733179
): Promise<void> =>
3174-
abortable(trackPromptSettlePromise(activeSession.prompt(prompt, options)));
3180+
withOwnedSessionTranscriptWrites(
3181+
{
3182+
sessionFile: params.sessionFile,
3183+
sessionKey: params.sessionKey,
3184+
withSessionWriteLock: (operation) =>
3185+
sessionLockController.withSessionWriteLock(operation),
3186+
},
3187+
async () => abortable(trackPromptSettlePromise(activeSession.prompt(prompt, options))),
3188+
);
31753189

31763190
const subscription = subscribeEmbeddedPiSession(
31773191
buildEmbeddedSubscriptionParams({

0 commit comments

Comments
 (0)