-
Notifications
You must be signed in to change notification settings - Fork 139
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
Human intervention abstraction #121
Comments
Hi Maya, this ticket is super interesting and might be a good first iteration. This could be part of a larger "epic" of work enabling human-in-the-loop interaction. The human as a tool is valid for cases when the agent determines the need to call out to a human for more information, but a complementary paradigm for the framework developers might be building agents with predefined points of validation and corrections from the end user. So having a concept similar to the Eg:
In a more complex case, the end user may also be able to rerun previous prompt with adapted tool inputs that they observed were used by the agent last time. |
thanks for the feedback @prattyushmangal - would you be open to contributing this? |
Hi @mmurad2 , I find this issue very interesting and would love to contribute! I'm new to the Bee Framework but have experience developing an agent-based product with a custom framework, which I'm now migrating to Bee. This feature aligns closely with patterns I've worked on, and I'd be thrilled to help implement it. Is someone already working on this, or can I take the issue? Thanks |
@matiasmolinas just assigned to you :) @prattyushmangal has been thinking about human intervention and can help provide feedback. Also @Tomas2D if you have any specific input on this, please do share! |
Hey everyone, yep this works for me too, apologies was not able to commit to completely contributing this feature. Happy to help @matiasmolinas where you need. Once we have a pattern for "pausing execution" to collect inputs from humans by implementing the |
Hi everyone! Thank you for the feedback and support on this issue. I’ve brainstormed a solution using GitHub Copilot Workspace to address the need for human intervention during an agent's workflow. Below is the proposed approach, incorporating feedback and outlining how I plan to implement the feature: Current Observations Triggering the Human Intervention Tool Update the BeeAgentRunner class to recognize "HumanTool" in the parser regex. Tool Name: "HumanTool". Define "HumanTool" as part of the BeeAgent’s tools. Add "HumanTool" to the BeeAgentRunner parser regex. The workflow will resume from where it was paused after collecting human inputs. Before I move too far ahead, I’d appreciate your feedback, especially on: The selected approaches for triggering human intervention and resuming workflows. |
Hi Matias, Thank you for your thoughts on this issue already. Here are my thoughts. Step 1: Define the 'HumanTool' as a tool which can be equipped to any Bee and be invoked by it when it deems there is some missing information required for the following steps and hence must call out to the user to collect it. So I agree with you on the following:
Step 2: Is repurposing this HumanTool pattern for other, developer defined interventions. But I propose that we defer this to a secondary issue once we have implemented a pattern for HumanTool which the Bee Agents can use for info gathering. |
For the technical details on:
|
Thank you for the detailed guidelines! I’ll share updates as I progress! |
…vention Abstraction
Hi all, I’ve published a branch containing the first working draft, which I’m currently refactoring and refining. You can find it here: Key Points and Observations: I’m using OpenAI’s GPT-4 for generating responses and have been defining/modifying prompts as part of this draft. I noticed that the conditions for calling HumanTool aren’t well-defined. My current assumption is that it should be triggered when additional information is required to achieve a goal, but this needs further refinement to ensure consistency and reliability. The draft works for a very simple use case in its "happy path." This provides a starting point for making the solution more generic and identifying and fixing bugs. I edited some existing classes and prompts for this draft. While this approach is acceptable for internal testing, I plan to refactor these changes in the final version to ensure a cleaner implementation. The final version will use my own extensions and classes to maintain modularity and readability. Thanks! Let me know your thoughts. |
This is a sample output of the current draft:
|
Summary of work in progressKey Updates
Workflow Comparison: Before and After the Update
Benefits of the Update
Sequence DiagramsBefore UpdatesequenceDiagram
participant User
participant ConsoleReader
participant BeeAgent
participant LLM
participant Tools
participant Memory
User->>ConsoleReader: Provide Input
ConsoleReader->>BeeAgent: Submit Prompt
BeeAgent->>LLM: Generate Initial Response
LLM-->>BeeAgent: Provide Output
BeeAgent->>Tools: Invoke Tools (if required)
Tools-->>BeeAgent: Return Results
BeeAgent->>Memory: Update Memory
BeeAgent-->>ConsoleReader: Deliver Response
After UpdatesequenceDiagram
participant User
participant ConsoleReader
participant BeeAgent
participant LLM
participant HumanTool
participant Tools
participant Memory
User->>ConsoleReader: Provide Input
ConsoleReader->>BeeAgent: Submit Prompt
BeeAgent->>LLM: Generate Initial Response
LLM-->>BeeAgent: Decide to Use HumanTool
BeeAgent->>HumanTool: Request User Input
HumanTool-->>User: Display Message and Await Response
User->>HumanTool: Provide Input
HumanTool-->>BeeAgent: Return User Input
BeeAgent->>Tools: Invoke Tools (if required)
Tools-->>BeeAgent: Return Results
BeeAgent->>Memory: Update Memory
BeeAgent-->>ConsoleReader: Deliver Final Response
|
Hi everyone, I’ve implemented the first version of the HumanTool and integrated it into the BeeAgent framework. You can find my work in my fork here: human-tool branch. Key Updates:
I plan to review and refine this implementation tomorrow. If everything works as expected during testing, I will create a pull request to merge these changes into the main repository. If there are any specific areas you’d like me to double-check or additional feedback before the PR, feel free to let me know. Thank you for the guidance and support on this issue! |
Refactored \`human.ts\` to remove unused imports and variables: - Removed unused \`ToolOutput\` import. - Renamed \`options\` to \`_options\` to comply with linting rules for unused variables. Refactored \`io.ts\` to eliminate console statements: - Replaced \`console.error\` with comments for fallback handling. These changes ensure that \`yarn lint\` runs without errors or warnings. Ref: i-am-bee#121
…iles Ref: i-am-bee#121 Signed-off-by: Matias Molinas <[email protected]>
Ref: i-am-bee#121 Signed-off-by: Matias Molinas <[email protected]>
Ref: i-am-bee#121 Signed-off-by: Matias Molinas <[email protected]>
Ref: i-am-bee#121 Signed-off-by: Matias Molinas <[email protected]>
…orking example Ref: i-am-bee#121
… and optimize testing Refactored \humantool_agent.ts\ based on PR feedback: - Retained the original system prompt to prevent unnecessary changes. - Adjusted testing to use LLaMA instead of GPT-4 as per optimization requirements. - Addressed issues where the model occasionally skipped tool calling. Ref: i-am-bee#121 Signed-off-by: Matias Molinas <[email protected]>
Removed the extended prompt for the human tool, enhanced the tool description, and updated the example to use the default system prompt. Ref: i-am-bee#121 Signed-off-by: Matias Molinas <[email protected]>
…iles Ref: i-am-bee#121 Signed-off-by: Matias Molinas <[email protected]>
Ref: i-am-bee#121 Signed-off-by: Matias Molinas <[email protected]>
Ref: i-am-bee#121 Signed-off-by: Matias Molinas <[email protected]>
Ref: i-am-bee#121 Signed-off-by: Matias Molinas <[email protected]>
…orking example Ref: i-am-bee#121 Signed-off-by: Matias Molinas <[email protected]>
… and optimize testing Refactored \humantool_agent.ts\ based on PR feedback: - Retained the original system prompt to prevent unnecessary changes. - Adjusted testing to use LLaMA instead of GPT-4 as per optimization requirements. - Addressed issues where the model occasionally skipped tool calling. Ref: i-am-bee#121 Signed-off-by: Matias Molinas <[email protected]>
Removed the extended prompt for the human tool, enhanced the tool description, and updated the example to use the default system prompt. Ref: i-am-bee#121 Signed-off-by: Matias Molinas <[email protected]>
Ref: i-am-bee#121 Signed-off-by: Matias Molinas <[email protected]>
@mmurad2 @prattyushmangal I created a PR with a basic implementation of what @prattyushmangal define as step 1: Step 1: Define the 'HumanTool' as a tool which can be equipped to any Bee and be invoked by it when it deems there is some missing information required for the following steps and hence must call out to the user to collect it. So I agree with you on the following: Tool Name: 'HumanTool' In the meantime, while the PR is approved or a change is requested, I am working on step 2: Step 2: Is repurposing this HumanTool pattern for other, developer defined interventions. But I propose that we defer this to a secondary issue once we have implemented a pattern for HumanTool which the Bee Agents can use for info gathering. Taking into account the original idea: The human as a tool is valid for cases when the agent determines the need to call out to a human for more information, but a complementary paradigm for the framework developers might be building agents with predefined points of validation and corrections from the end user. So having a concept similar to the emitter for observing agent behaviour might be useful to have a concept that allows developers to pause and resume agent behaviour with a human interaction in the middle. Eg: Validate Step/Tool to call Here is my question: Should I implement step 2 using the same issue ID and create a new PR, or do I need to create a new issue to implement it? |
@mmurad2 @prattyushmangal I’ve created a PR for Step 1 implementing the HumanTool as defined: Tool Name: HumanTool In parallel, I’m working on Step 2 to repurpose the HumanTool for additional developer-defined interventions, integrating it with the new RePlanAgent. This involves creating an InterventionTool and an InterventionManager to handle validations and corrections, leveraging the RePlanAgent's planning and event-driven capabilities. Should I continue using this issue ID for Step 2 and submit a new PR, or would it be better to create a separate issue for implementing the human intervention abstraction? |
Difference Between HumanTool and Human InterventionI'm currently working on distinguishing between HumanTool and Human Intervention to establish a clear and structured approach for human-in-the-loop interactions within the Bee framework. This is a work in progress, and I welcome any feedback or suggestions to refine these concepts further. HumanToolDefinition:
Key Characteristics:
Example:
Human InterventionDefinition:
Key Characteristics:
Usage Scenario:
Summary of Differences
How They Work Together
This is an ongoing effort, and I plan to further develop these concepts to enhance the agent's interaction capabilities. Any feedback or insights would be greatly appreciated! |
Added human.ts to experimental tools and human.ts to agents. Updated io.ts in helpers to support the new tool. Ref: i-am-bee#121 Signed-off-by: Matias Molinas <[email protected]>
- Add InterventionTool for handling human interactions - Implement InterventionManager for managing intervention events - Extend RePlan agent to support intervention events - Add intervention-aware system prompt - Add intervention event types to RePlanEvents Ref: i-am-bee#121 Signed-off-by: Matias Molinas <[email protected]>
Hey Matias, thank you for your work on this issue. With regards to your question I think the human intervention should be a separate ticket and separate PR to make it easier for you and for reviewers most likely. For the human intervention piece, I imagine an initial PR which demonstrates how an agent can refer back to the end user to validate the step selected and the parameters selected would be a good first pass. In followup work, that could be abstracted to an intervention class, that you mention, that each Agent can utilise and then switch on the Human Intervention features based on a flag at runtime. Hope that helps. |
Thank you for the feedback, @prattyushmangal! Here’s how I plan to proceed based on your suggestions: Separate Issue and PRI’ll create a new issue and PR specifically for the human intervention abstraction. This will keep the scope focused and easier for reviewers to follow, as suggested. Initial PR Scope: Full Support for Validation, Basic Support for Correction and Clarification, and the Intervention ClassTo ensure a robust design and implementation, the initial PR will include:
Examples of Human Intervention ScenariosTo align with your request, I’ll include examples for validation, correction, and clarification:
Planned Implementation
|
I forgot to mention earlier that human intervention will be integrated with RePlan to make the framework more adaptive and capable of handling nuanced, real-world scenarios. This integration introduces the By seamlessly blending automation with human oversight, RePlan can support a broader range of complex scenarios while maintaining accuracy, adaptability, and trustworthiness. Here’s how this integration expands RePlan’s capabilities:
Examples of Scenarios Leveraging Human Intervention
Integrating human intervention with RePlan not only enhances the assistant's flexibility but also allows it to confidently tackle scenarios that demand both automation and human insight. This addition ensures that RePlan remains reliable, adaptive, and user-focused while supporting a wider variety of complex use cases. |
Ref: i-am-bee#121 Signed-off-by: Matias Molinas <[email protected]>
…ustment - Added basic structure for handling user input during plan adjustments. Ref: i-am-bee#121 Signed-off-by: Matias Molinas <[email protected]>
- Improved the description for the human tool to better reflect its capabilities and usage. - Ensures clarity and consistency with other tool descriptions. Ref: i-am-bee#121 Signed-off-by: Matias Molinas <[email protected]>
Is your feature request related to a problem? Please describe.
For certain use cases, the agent requires additional information or steering from the user in order to execute correctly.
Describe the solution you'd like
An abstraction that calls for human intervention during a single agent's workflow. This could be consider a "tool" that can be configured for a certain use case. I would assume the agent builder would need to define when this "tool" should be used.
The text was updated successfully, but these errors were encountered: