Agents: harden after-turn runtime context
This commit is contained in:
parent
78593ccf84
commit
ea8ef0697e
@ -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: [],
|
||||
|
||||
@ -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: [],
|
||||
|
||||
@ -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: {
|
||||
|
||||
@ -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<CompactEmbeddedPiSessionParams> {
|
||||
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,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -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",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user