Skip to content
Merged
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
23 changes: 23 additions & 0 deletions packages/agent-runtime/src/codex/adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2692,6 +2692,29 @@ describe("codex provider adapter", () => {
expect(events).toEqual([]);
});

it("translateEvent ignores Codex raw response completions", () => {
const adapter = createCodexProviderAdapter();
const events = adapter.translateEvent({
jsonrpc: "2.0",
method: "rawResponse/completed",
params: {
threadId: "t1",
turnId: "turn-1",
responseId: "response-1",
usage: {
totalTokens: 19_206,
inputTokens: 18_971,
cachedInputTokens: 11_008,
cacheWriteInputTokens: 0,
outputTokens: 235,
reasoningOutputTokens: 53,
},
},
});

expect(events).toEqual([]);
});

it("translateEvent item/mcpToolCall/progress maps to shared tool progress", () => {
const adapter = createCodexProviderAdapter();
const events = adapter.translateEvent(
Expand Down
10 changes: 9 additions & 1 deletion packages/agent-runtime/src/codex/visibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import {
} from "../shared/provider-visibility-helpers.js";
import type { ServerNotification } from "./generated/codex-app-server/schema/ServerNotification.js";

type CodexServerNotificationMethod = ServerNotification["method"];
type CodexServerNotificationMethod =
| ServerNotification["method"]
// Visibility can lead the independently refreshed generated schema when a
// newer installed Codex starts emitting a notification.
| "rawResponse/completed";

interface CodexNotificationRawEvent {
kind: "notification";
Expand Down Expand Up @@ -80,6 +84,7 @@ const CODEX_SERVER_NOTIFICATION_METHODS = {
"model/rerouted": true,
"process/exited": true,
"process/outputDelta": true,
"rawResponse/completed": true,
"rawResponseItem/completed": true,
"remoteControl/status/changed": true,
"serverRequest/resolved": true,
Expand Down Expand Up @@ -158,6 +163,9 @@ const CODEX_NOTIFICATION_COVERAGE = {
// there is nothing to surface — left "unknown" intentionally.
"process/exited": "unknown",
"process/outputDelta": "unknown",
// Internal per-response accounting; thread/tokenUsage/updated carries the
// user-facing token state.
"rawResponse/completed": "noise",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 slopcop/review — P3: Stop this unused notification at the source.

BB enables experimentalRawEvents because it needs rawResponseItem/completed for command output recovery.

However, BB does not use rawResponse/completed.

This patch drops the notification only after Codex creates, serializes, sends, and BB parses it.

Codex supports an exact method filter through initialize.params.capabilities.optOutNotificationMethods.

Please add rawResponse/completed to that list and test the initialize request.

This change keeps required item events and avoids work for each upstream response.

"rawResponseItem/completed": "noise",
"remoteControl/status/changed": "noise",
"serverRequest/resolved": "noise",
Expand Down
25 changes: 25 additions & 0 deletions packages/agent-runtime/src/provider-visibility.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,29 @@ describe("provider visibility raw events", () => {
coverage: "noise",
});
});

it("classifies Codex raw response completions as noise", () => {
expect(
codexVisibilityMetadata.describeRawEvent({
jsonrpc: "2.0",
method: "rawResponse/completed",
params: {
threadId: "thread-1",
turnId: "turn-1",
responseId: "response-1",
usage: {
totalTokens: 19_206,
inputTokens: 18_971,
cachedInputTokens: 11_008,
cacheWriteInputTokens: 0,
outputTokens: 235,
reasoningOutputTokens: 53,
},
},
}),
).toEqual({
kind: "rawResponse/completed",
coverage: "noise",
});
});
});
2 changes: 1 addition & 1 deletion packages/host-daemon-contract/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
providerCliStatusResponseSchema,
} from "./local.js";

export const HOST_DAEMON_PROTOCOL_VERSION = 96 as const;
export const HOST_DAEMON_PROTOCOL_VERSION = 97 as const;

export {
BRANCH_LIST_LIMIT_MAX,
Expand Down
9 changes: 5 additions & 4 deletions packages/host-daemon-contract/test/contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1051,10 +1051,11 @@ describe("host-daemon local schemas", () => {
});

describe("host-daemon command schemas", () => {
// Version 96 adds provider-native skill discovery roots. An older daemon
// returns an incomplete skill catalog, so it must update before connecting.
it("uses protocol version 96 for provider-native skill discovery", () => {
expect(HOST_DAEMON_PROTOCOL_VERSION).toBe(96);
// Version 97 suppresses Codex raw response completion notifications. An
// older daemon emits them as provider/unhandled, so it must update before
// connecting.
it("uses protocol version 97 for Codex raw response completion noise", () => {
expect(HOST_DAEMON_PROTOCOL_VERSION).toBe(97);
});

it("binds Plan cancellation to a required turn id and typed result", () => {
Expand Down
Loading