CopilotKit / CopilotKit/CopilotKit
🚀 Feature Request: Respond to tool call without followUp
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 37.4k
- Forks
- 4.6k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 444
Description
🎤 Tell us your idea
Idea
I'd like to use AppendMessageOptions or only the followUp option when using the respond function from useHumanInTheLoop to have better control over the messages before an agent response is generated.
Use Case
I'm currently using useHumanInTheLoop to enable the agent to propose a list of elements to be created to the user that the user can edit and apply.
However the user should also be able to send a message with additional information and instructions if the proposition didn't meet their expectations.
If there is an unapproved tool call and the user sends their message, I want to first set a "rejected" tool result so that the tool call is completed gracefully and then send the message. Both - the user message and the tool result - should be send together to give the agent the full picture before a reply is generated.
In the sendMessage method I can use the optional AppendMessageOptions which offer the followUp option to tell CopilotKit to not immediately send the message.
In the respond method offered by useHumanInTheLoop these options are not exposed - instead followUp can currently only be configured in the arguments of useHumanInTheLoop beforehand.
If I understand it correctly, if the followUp option could be set when calling respond, I should be able to register the tool result "silently" and have it automatically be sent as soon as sendMessage is called with followUp: true.
To summarize my ideal scenario:
- Agent executes frontend tool
- User sends a message
2.1. Frontend tool is gracefully completed callingrespondwith "rejection" result andfollowUp: false
2.2. User message is sent callingsendMessagewithfollowUp: true
2.3. CopilotKit sends both messages and triggers a new generation - Agent can reference the user decision to reject the proposition from the first tool call and their new instructions to continue the dialogue or execute frontend tool again with improved proposition
In a nutshell:
// at design time (currently supported)
useHumanInTheLoop({
followUp: true, // sets the default value
});
// at runtime (currently not supported)
respond(result, {
followUp: false, // overwrites the default value if supplied
})
// at runtime (currently supported)
sendMessage(userMessage, {
followUp: true, // sends two messages (the tool result above and the user message created here)
})
Related Issues
#3154 Might be related, because they also needed to set followUp: false when calling useHumanInTheLoop and then manually call sendMessage with followUp: true inside the render function
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the TypeScript definitions and implementation of useHumanInTheLoop, respond, sendMessage, and AppendMessageOptions. Check how followUp is currently configured and how messages are queued. Done means respond can accept a runtime followUp override so a tool result and subsequent user message are sent together before a new generation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- api, frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 64/100