Support multiple messages in agent.prompt() and agentLoop
- agentLoop now accepts AgentMessage[] instead of single message - agent.prompt() accepts AgentMessage | AgentMessage[] - Emits message_start/end for each message in the array - AgentSession.prompt() builds array with hook message + user message - TUI now receives events for before_agent_start injected messages
This commit is contained in:
@@ -105,7 +105,7 @@ describe("agentLoop with AgentMessage", () => {
|
||||
};
|
||||
|
||||
const events: AgentEvent[] = [];
|
||||
const stream = agentLoop(userPrompt, context, config, undefined, streamFn);
|
||||
const stream = agentLoop([userPrompt], context, config, undefined, streamFn);
|
||||
|
||||
for await (const event of stream) {
|
||||
events.push(event);
|
||||
@@ -172,7 +172,7 @@ describe("agentLoop with AgentMessage", () => {
|
||||
};
|
||||
|
||||
const events: AgentEvent[] = [];
|
||||
const stream = agentLoop(userPrompt, context, config, undefined, streamFn);
|
||||
const stream = agentLoop([userPrompt], context, config, undefined, streamFn);
|
||||
|
||||
for await (const event of stream) {
|
||||
events.push(event);
|
||||
@@ -224,7 +224,7 @@ describe("agentLoop with AgentMessage", () => {
|
||||
return stream;
|
||||
};
|
||||
|
||||
const stream = agentLoop(userPrompt, context, config, undefined, streamFn);
|
||||
const stream = agentLoop([userPrompt], context, config, undefined, streamFn);
|
||||
|
||||
for await (const _ of stream) {
|
||||
// consume
|
||||
@@ -288,7 +288,7 @@ describe("agentLoop with AgentMessage", () => {
|
||||
};
|
||||
|
||||
const events: AgentEvent[] = [];
|
||||
const stream = agentLoop(userPrompt, context, config, undefined, streamFn);
|
||||
const stream = agentLoop([userPrompt], context, config, undefined, streamFn);
|
||||
|
||||
for await (const event of stream) {
|
||||
events.push(event);
|
||||
@@ -351,7 +351,7 @@ describe("agentLoop with AgentMessage", () => {
|
||||
};
|
||||
|
||||
const events: AgentEvent[] = [];
|
||||
const stream = agentLoop(userPrompt, context, config, undefined, (_model, ctx, _options) => {
|
||||
const stream = agentLoop([userPrompt], context, config, undefined, (_model, ctx, _options) => {
|
||||
// Check if interrupt message is in context on second call
|
||||
if (callIndex === 1) {
|
||||
sawInterruptInContext = ctx.messages.some(
|
||||
|
||||
Reference in New Issue
Block a user