-
Notifications
You must be signed in to change notification settings - Fork 130
[ai] Make DurableAgent#stream() return a messages array
#362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ai] Make DurableAgent#stream() return a messages array
#362
Conversation
🦋 Changeset detectedLatest commit: a71caa8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| const toolResult = await tool.execute(input.value, { | ||
| toolCallId: toolCall.toolCallId, | ||
| // TODO: pass the proper messages to the tool | ||
| // TODO: pass the proper messages to the tool (we'd need to pass them through the iterator) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wdym by that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From claude, but I guess it's saying that each yield from the iterator needs to pass the current state of messages as well as the toolCalls. This part isn't currently being provided here anyways so I'll save figuring that part out for a later PR.
| } | ||
| } | ||
|
|
||
| return conversationPrompt; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wdyt?
| return conversationPrompt; | |
| return { messages: conversationPrompt}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with it, but it's also not really important because this is not the public facing API, we could easily refactor later if we need to return more information.
pranaygp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left some nits and docs comments but otherwise lgtm
DurableAgent#stream() return a messages arrayDurableAgent#stream() return a messages array
a8c9d48 to
2340289
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 Build Fix:
The if (!input?.success) block is missing a closing brace, causing a syntax error that prevents TypeScript compilation from completing. The try statement on line 218 cannot be parsed without the closing brace.
View Details
📝 Patch Details
diff --git a/packages/ai/src/agent/durable-agent.ts b/packages/ai/src/agent/durable-agent.ts
index 9b19067..0a3dd43 100644
--- a/packages/ai/src/agent/durable-agent.ts
+++ b/packages/ai/src/agent/durable-agent.ts
@@ -216,6 +216,7 @@ async function executeTool(
throw new Error(
`Invalid input for tool "${toolCall.toolName}": ${input?.error?.message}`
);
+ }
try {
const toolResult = await tool.execute(input.value, {
Analysis
Missing closing brace in TypeScript async function causes syntax error
What fails: TypeScript compiler fails on packages/ai/src/agent/durable-agent.ts due to missing closing brace in the executeTool function
How to reproduce:
cd packages/ai
npx tsc --noEmitResult:
src/agent/durable-agent.ts(254,1): error TS1005: '}' expected.
Root cause: The if (!input?.success) block at line 215 was missing a closing brace before the try statement at line 218, causing a syntax error that prevents TypeScript compilation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 Build Fix:
The if (!input?.success) block is missing its closing brace }, causing TypeScript to expect the brace at the start of the following try block instead. This syntax error prevents the entire package from compiling.
View Details
📝 Patch Details
diff --git a/packages/ai/src/agent/durable-agent.ts b/packages/ai/src/agent/durable-agent.ts
index 9b19067..0a3dd43 100644
--- a/packages/ai/src/agent/durable-agent.ts
+++ b/packages/ai/src/agent/durable-agent.ts
@@ -216,6 +216,7 @@ async function executeTool(
throw new Error(
`Invalid input for tool "${toolCall.toolName}": ${input?.error?.message}`
);
+ }
try {
const toolResult = await tool.execute(input.value, {
Analysis
Missing closing brace in executeTool function causes TypeScript compilation failure
What fails: TypeScript compiler fails to parse src/agent/durable-agent.ts due to a missing closing brace for the if (!input?.success) conditional block in the executeTool function.
How to reproduce:
cd packages/ai && npm run buildResult:
src/agent/durable-agent.ts(254,1): error TS1005: '}' expected.
What was wrong: The if (!input?.success) block on line 216-220 was missing its closing brace }. The try block immediately following it on line 222 appeared without the if block being properly terminated, causing a syntax error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 Build Fix:
The if (!input?.success) conditional block was missing a closing brace }, causing the TypeScript compiler to fail with a syntax error at the end of the file.
View Details
📝 Patch Details
diff --git a/packages/ai/src/agent/durable-agent.ts b/packages/ai/src/agent/durable-agent.ts
index 9b19067..0a3dd43 100644
--- a/packages/ai/src/agent/durable-agent.ts
+++ b/packages/ai/src/agent/durable-agent.ts
@@ -216,6 +216,7 @@ async function executeTool(
throw new Error(
`Invalid input for tool "${toolCall.toolName}": ${input?.error?.message}`
);
+ }
try {
const toolResult = await tool.execute(input.value, {
Analysis
Missing closing brace in executeTool function causes TypeScript compilation failure
What fails: TypeScript compiler fails on @workflow/ai package build due to missing closing brace in src/agent/durable-agent.ts
How to reproduce:
cd packages/ai && pnpm run buildResult (before fix):
src/agent/durable-agent.ts(254,1): error TS1005: '}' expected.
ELIFECYCLE Command failed with exit code 2.
Root cause: The if (!input?.success) block at line 216 was missing its closing brace, causing the TypeScript parser to expect a closing brace at the end of the file (line 254).
Fix applied: Added missing closing brace } after the error throw statement in the if (!input?.success) block to properly close the conditional block before the try statement.

Updated
DurableAgent#stream()to return amessagesarray containing the full conversation history.What changed?
DurableAgent#stream()to return an object with amessagesproperty containing the complete conversation historyHow to test?
agent.stream()with initial messagesmessagesarray with the full conversationagent.stream()call to continue the conversationWhy make this change?
This change makes it easier to build multi-turn conversations with DurableAgent by providing access to the complete conversation history. Previously, developers had to manually track and maintain the conversation state between interactions. Now, the agent returns the full message history, which can be directly used in subsequent calls, simplifying the implementation of conversational agents that maintain context across multiple interactions.