Skip to content
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

feat(agents): retry on a parser error #204

Merged
merged 1 commit into from
Dec 2, 2024
Merged

Conversation

Tomas2D
Copy link
Contributor

@Tomas2D Tomas2D commented Nov 30, 2024

Retry if LLM generates something that does not adhere to the communication structure defined in the system prompt.

TODOs:

  • improves the "error" prompt
  • consider using another "role"
  • consider whether to remove the message after successful generation or not

@Tomas2D Tomas2D requested a review from a team as a code owner November 30, 2024 11:21
export const BeeSchemaErrorPrompt = new PromptTemplate({
schema: z.object({}).passthrough(),
template: `Error: The generated response does not adhere to the communication structure mentioned in the system prompt.
You communicate only in instruction lines. Valid instruction lines are 'Thought' followed by either 'Function Name' + 'Function Input' + 'Function Output' or 'Final Answer'.`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idea (to test in prompt lab): Should we repeat the exact instructions from the system prompt?

How about extracting the "communication structure" section of the system prompt to a separate variable similar to instructions and using it here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that the communication structure is dynamic. The presence of tools influences it.

See

{{/tools.length}}
# Communication structure
You communicate only in instruction lines. The format is: "Instruction: expected output". You must only use these instruction lines and must not enter empty lines or anything else between instruction lines.
{{#tools.length}}
You must skip the instruction lines Function Name, Function Input and Function Output if no function calling is required.
{{/tools.length}}

So I am not sure whether it is worth it to introduce a new system, PromptTemplate, that is going to be used as part of BeeSystemPrompt. I would keep it as is.

@Tomas2D Tomas2D force-pushed the feat/agent-parser-retry branch from 6cab707 to 3a92aa7 Compare December 2, 2024 18:33
@Tomas2D Tomas2D merged commit 226aaf5 into main Dec 2, 2024
4 checks passed
@Tomas2D Tomas2D deleted the feat/agent-parser-retry branch December 2, 2024 18:36
tonxxd pushed a commit to tonxxd/bee-agent-framework that referenced this pull request Dec 3, 2024
matiasmolinas pushed a commit to matiasmolinas/bee-agent-framework that referenced this pull request Dec 3, 2024
Signed-off-by: Tomas Dvorak <[email protected]>
Signed-off-by: Matias Molinas <[email protected]>
matiasmolinas pushed a commit to matiasmolinas/bee-agent-framework that referenced this pull request Dec 7, 2024
Signed-off-by: Tomas Dvorak <[email protected]>
Signed-off-by: Matias Molinas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants