diff --git a/src/agents/gigachat-stream.leaked-prelude.test.ts b/src/agents/gigachat-stream.leaked-prelude.test.ts index 84ca6923957..251516566c1 100644 --- a/src/agents/gigachat-stream.leaked-prelude.test.ts +++ b/src/agents/gigachat-stream.leaked-prelude.test.ts @@ -37,7 +37,7 @@ describe("GigaChat leaked function-call prelude cleanup", () => { authMode: "oauth", }); - const stream = streamFn( + const stream = await streamFn( { api: "gigachat", provider: "gigachat", id: "GigaChat-2-Max" } as never, { messages: [], diff --git a/src/agents/gigachat-stream.tool-calls.test.ts b/src/agents/gigachat-stream.tool-calls.test.ts index 741c5362bea..ff41acae97e 100644 --- a/src/agents/gigachat-stream.tool-calls.test.ts +++ b/src/agents/gigachat-stream.tool-calls.test.ts @@ -47,7 +47,7 @@ describe("createGigachatStreamFn tool calling", () => { authMode: "oauth", }); - const stream = streamFn( + const stream = await streamFn( { api: "gigachat", provider: "gigachat", id: "GigaChat-2-Max" } as never, { messages: [], @@ -103,7 +103,7 @@ describe("createGigachatStreamFn tool calling", () => { authMode: "oauth", }); - const stream = streamFn( + const stream = await streamFn( { api: "gigachat", provider: "gigachat", id: "GigaChat-2-Max" } as never, { messages: [ @@ -249,7 +249,7 @@ describe("createGigachatStreamFn tool calling", () => { authMode: "oauth", }); - const stream = streamFn( + const stream = await streamFn( { api: "gigachat", provider: "gigachat", id: "GigaChat-2-Max" } as never, { messages: [], @@ -292,7 +292,7 @@ describe("createGigachatStreamFn tool calling", () => { scope: "GIGACHAT_API_PERS", }); - const stream = streamFn( + const stream = await streamFn( { api: "gigachat", provider: "gigachat", id: "GigaChat-2-Max" } as never, { messages: [], diff --git a/src/agents/pi-embedded-runner/run/attempt.test.ts b/src/agents/pi-embedded-runner/run/attempt.test.ts index be8eafaccec..f72d1fa5034 100644 --- a/src/agents/pi-embedded-runner/run/attempt.test.ts +++ b/src/agents/pi-embedded-runner/run/attempt.test.ts @@ -1179,6 +1179,18 @@ describe("prependSystemPromptAddition", () => { }); describe("buildAfterTurnRuntimeContext", () => { + it("returns workspace-only context when attempt data is missing", () => { + const legacy = buildAfterTurnRuntimeContext({ + workspaceDir: "/tmp/workspace", + agentDir: "/tmp/agent", + }); + + expect(legacy).toEqual({ + workspaceDir: "/tmp/workspace", + agentDir: "/tmp/agent", + }); + }); + it("uses primary model when compaction.model is not set", () => { const legacy = buildAfterTurnRuntimeContext({ attempt: { diff --git a/src/agents/pi-embedded-runner/run/attempt.ts b/src/agents/pi-embedded-runner/run/attempt.ts index 7a74332af55..081b902d121 100644 --- a/src/agents/pi-embedded-runner/run/attempt.ts +++ b/src/agents/pi-embedded-runner/run/attempt.ts @@ -1294,7 +1294,7 @@ export function prependSystemPromptAddition(params: { /** Build runtime context passed into context-engine afterTurn hooks. */ export function buildAfterTurnRuntimeContext(params: { - attempt: Pick< + attempt?: Pick< EmbeddedRunAttemptParams, | "sessionKey" | "messageChannel" @@ -1315,24 +1315,25 @@ export function buildAfterTurnRuntimeContext(params: { workspaceDir: string; agentDir: string; }): Partial { + const attempt = params.attempt; return { - sessionKey: params.attempt.sessionKey, - messageChannel: params.attempt.messageChannel, - messageProvider: params.attempt.messageProvider, - agentAccountId: params.attempt.agentAccountId, - authProfileId: params.attempt.authProfileId, + sessionKey: attempt?.sessionKey, + messageChannel: attempt?.messageChannel, + messageProvider: attempt?.messageProvider, + agentAccountId: attempt?.agentAccountId, + authProfileId: attempt?.authProfileId, workspaceDir: params.workspaceDir, agentDir: params.agentDir, - config: params.attempt.config, - skillsSnapshot: params.attempt.skillsSnapshot, - senderIsOwner: params.attempt.senderIsOwner, - provider: params.attempt.provider, - model: params.attempt.modelId, - thinkLevel: params.attempt.thinkLevel, - reasoningLevel: params.attempt.reasoningLevel, - bashElevated: params.attempt.bashElevated, - extraSystemPrompt: params.attempt.extraSystemPrompt, - ownerNumbers: params.attempt.ownerNumbers, + config: attempt?.config, + skillsSnapshot: attempt?.skillsSnapshot, + senderIsOwner: attempt?.senderIsOwner, + provider: attempt?.provider, + model: attempt?.modelId, + thinkLevel: attempt?.thinkLevel, + reasoningLevel: attempt?.reasoningLevel, + bashElevated: attempt?.bashElevated, + extraSystemPrompt: attempt?.extraSystemPrompt, + ownerNumbers: attempt?.ownerNumbers, }; } diff --git a/src/commands/auth-choice.test.ts b/src/commands/auth-choice.test.ts index 146be1930f3..5606324b942 100644 --- a/src/commands/auth-choice.test.ts +++ b/src/commands/auth-choice.test.ts @@ -336,7 +336,7 @@ describe("applyAuthChoice", () => { mode: "api_key", }); expect(result.agentModelOverride).toBe("gigachat/GigaChat-2-Max"); - expect(resolveAgentModelPrimaryValue(result.config)).toBeUndefined(); + expect(resolveAgentModelPrimaryValue(result.config.agents?.defaults?.model)).toBeUndefined(); expect(await readAuthProfile("gigachat:default")).toMatchObject({ type: "api_key", provider: "gigachat",