-
Notifications
You must be signed in to change notification settings - Fork 73
feat: add text based tool updates for agentic-chat #984
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
Conversation
This looks amazing! 🕺 |
const results: ToolResult[] = [] | ||
|
||
for (const toolUse of toolUses) { | ||
if (!toolUse.name || !toolUse.toolUseId) continue | ||
|
||
try { | ||
this.#debug(`Running tool ${toolUse.name} with input:`, JSON.stringify(toolUse.input)) | ||
await chatResultStream.writeResultBlock({ body: `${executeToolMessage(toolUse)}` }) |
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.
Not needed for this PR: Is it also possible to update a previous block? I imagine the UX showing 'pending' .. 'in progress' ... 'done', or hiding confirmation buttons, etc.
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.
Once a block is added, its committed. This was an intentional choice to minimize interacting with state, and treat the block store as persistent.
However, you could use the stream writer to implement a progress block that renders 'in progress', 'pending', etc. until the actual resulting block is committed. The streaming writer doesn't commit any blocks to the store until it is closed (in this example, the result is resolved).
async #sendProgressToClient(chunk: ChatResult | string, partialResultToken?: string | number) { | ||
if (!isNullish(partialResultToken)) { | ||
await this.#features.lsp.sendProgress(chatRequestType, partialResultToken, chunk) | ||
} | ||
} |
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 love how you've been able to keep updating the client a separate concern from the agent loop and from the tool execution itself. Really flexible approach!
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.
Thanks, that way my goal!
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.
Awesome PR!
Problem
There is no way to tell what tools the agent is running and what their results are.
Additionally, streaming content to the chat is currently done through
lsp.sendProgress
which does not provide meaningful interface to build up a response. For example, each call overwrites all previous data, and doesn't provide any guardrails to prevent this from happening accidentally.Solution
lsp.sendProgress
for streaming and writing result "blocks" back to the user.Demo
textUIDemo.mov
Known Issues
When the request to Q endpoint fails, the chat hangs.
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.