Skip to content

Commit b2a3c59

Browse files
committed
fix: accept a null steering _meta and dedupe the idleBehavior test
The ACP type allows `_meta: null`, so treat it like an absent `_meta` instead of rejecting the steer. Fold the unsupported-idleBehavior case into the malformed-metadata it.each list, which also asserts that no turn is started, and drop its standalone test.
1 parent f1246fa commit b2a3c59

2 files changed

Lines changed: 4 additions & 13 deletions

File tree

‎src/CodexAcpServer.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2803,7 +2803,8 @@ export class CodexAcpServer {
28032803
throw RequestError.invalidParams();
28042804
}
28052805
const meta = params["_meta"];
2806-
if (meta !== undefined && !isRecord(meta)) {
2806+
// The ACP type allows `_meta: null`; treat it like an absent `_meta`.
2807+
if (meta !== undefined && meta !== null && !isRecord(meta)) {
28072808
throw RequestError.invalidParams(undefined, "steering _meta must be an object");
28082809
}
28092810
const steering = meta?.["steering"];

‎src/__tests__/CodexACPAgent/steer-events.test.ts‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('_session/steering', () => {
4949
vi.clearAllMocks();
5050
});
5151

52-
it.each([undefined, {steering: {idleBehavior: "promptRequired"}}])('reports injected when the input joins the active turn (metadata: %j)', async (_meta) => {
52+
it.each([null, undefined, {steering: {idleBehavior: "promptRequired"}}])('reports injected when the input joins the active turn (metadata: %j)', async (_meta) => {
5353
const {mockFixture, sessionState, turnCompleted} = startActiveTurn();
5454
const turnSteerSpy = vi.spyOn(mockFixture.getCodexAppServerClient(), "turnSteer")
5555
.mockResolvedValue({turnId: "turn-id"});
@@ -266,25 +266,15 @@ describe('_session/steering', () => {
266266
})).rejects.toThrow(RequestError);
267267
});
268268

269-
it('rejects an unsupported idle behavior', async () => {
270-
const mockFixture = createCodexMockTestFixture();
271-
272-
await expect(mockFixture.getCodexAcpAgent().extMethod(SESSION_STEERING_METHOD, {
273-
sessionId: "session-id",
274-
prompt: [{type: "text", text: "follow-up"}],
275-
_meta: {steering: {idleBehavior: "startDetachedTurn"}},
276-
})).rejects.toThrow("unsupported steering idleBehavior");
277-
});
278-
279269
it.each([
280-
null,
281270
[],
282271
false,
283272
"invalid",
284273
{steering: null},
285274
{steering: []},
286275
{steering: "invalid"},
287276
{steering: {idleBehavior: null}},
277+
{steering: {idleBehavior: "startDetachedTurn"}},
288278
])('rejects malformed steering metadata without starting or injecting a turn (%j)', async (_meta) => {
289279
const mockFixture = createCodexMockTestFixture();
290280
const turnStartSpy = vi.spyOn(mockFixture.getCodexAppServerClient(), "turnStart");

0 commit comments

Comments
 (0)