fix(agent): simplify state API and update consumers fixes #2633

This commit is contained in:
Mario Zechner
2026-03-30 12:43:34 +02:00
parent 5e3852fc9c
commit cbe1a8b732
24 changed files with 829 additions and 1198 deletions

View File

@@ -278,12 +278,12 @@ describe("AgentSession auto-compaction queue resume", () => {
};
// Put both messages into agent state so estimateContextTokens can find the successful one
session.agent.replaceMessages([
session.agent.state.messages = [
{ role: "user", content: [{ type: "text", text: "hello" }], timestamp: Date.now() - 1000 },
successfulAssistant,
{ role: "user", content: [{ type: "text", text: "another prompt" }], timestamp: Date.now() + 500 },
errorAssistant,
]);
];
const runAutoCompactionSpy = vi
.spyOn(
@@ -328,10 +328,10 @@ describe("AgentSession auto-compaction queue resume", () => {
timestamp: Date.now(),
};
session.agent.replaceMessages([
session.agent.state.messages = [
{ role: "user", content: [{ type: "text", text: "hello" }], timestamp: Date.now() - 1000 },
errorAssistant,
]);
];
const runAutoCompactionSpy = vi
.spyOn(
@@ -407,12 +407,12 @@ describe("AgentSession auto-compaction queue resume", () => {
};
// Agent state has the kept assistant (pre-compaction) and the error (post-compaction)
session.agent.replaceMessages([
session.agent.state.messages = [
{ role: "user", content: [{ type: "text", text: "kept user msg" }], timestamp: preCompactionTimestamp - 1000 },
keptAssistant,
{ role: "user", content: [{ type: "text", text: "new prompt" }], timestamp: Date.now() - 500 },
errorAssistant,
]);
];
const runAutoCompactionSpy = vi
.spyOn(