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

[@giorgossideris] Add prompt rewriting for multiple messages in ReasoningAgent #1140

Merged
merged 24 commits into from
Feb 28, 2025

Conversation

BabyCNM
Copy link
Collaborator

@BabyCNM BabyCNM commented Feb 25, 2025

Why are these changes needed?

Main Contributor: @giorgossideris

Duplicates #758 and finish the pre-commit checks.

Resolve the issue: #755

Related issue number

Checks

giorgossideris and others added 6 commits February 3, 2025 00:04
* Enable code execution in reasoning agent

1. enable code execution
2. remove the "verbose" parameter, and replace with AG2's default "silent" parameter.

* init _user_proxy

* notebook update

* notebook update

* add test case for running code in reasoning agent

* use mock credential for reasoning test

* reasoning prompt update

* mock credentials for more tests

* Update .secrets.baseline

* clear notebook outputs

* remove variable F
@BabyCNM BabyCNM requested review from Hk669, davorrunje, marklysze and alecsolder and removed request for Hk669 February 25, 2025 23:24
BabyCNM and others added 5 commits February 25, 2025 16:24
* Enable code execution in reasoning agent

1. enable code execution
2. remove the "verbose" parameter, and replace with AG2's default "silent" parameter.

* init _user_proxy

* notebook update

* notebook update

* add test case for running code in reasoning agent

* use mock credential for reasoning test

* reasoning prompt update

* mock credentials for more tests

* Update .secrets.baseline

* clear notebook outputs

* remove variable F
* Fix swarm tests by including transit messages

* Fix for Gemini library for async use

* pre-commit fix
* Enable code execution in reasoning agent

1. enable code execution
2. remove the "verbose" parameter, and replace with AG2's default "silent" parameter.

* init _user_proxy

* notebook update

* notebook update

* add test case for running code in reasoning agent

* use mock credential for reasoning test

* reasoning prompt update

* mock credentials for more tests

* Update .secrets.baseline

* clear notebook outputs

* remove variable F
@BabyCNM BabyCNM changed the title Reasoning agent rewriting prompt ag2 [@giorgossideris] Add prompt rewriting for multiple messages in ReasoningAgent Feb 26, 2025
BabyCNM and others added 5 commits February 25, 2025 16:29
* Enable code execution in reasoning agent

1. enable code execution
2. remove the "verbose" parameter, and replace with AG2's default "silent" parameter.

* init _user_proxy

* notebook update

* notebook update

* add test case for running code in reasoning agent

* use mock credential for reasoning test

* reasoning prompt update

* mock credentials for more tests

* Update .secrets.baseline

* clear notebook outputs

* remove variable F
* Enable code execution in reasoning agent

1. enable code execution
2. remove the "verbose" parameter, and replace with AG2's default "silent" parameter.

* init _user_proxy

* notebook update

* notebook update

* add test case for running code in reasoning agent

* use mock credential for reasoning test

* reasoning prompt update

* mock credentials for more tests

* Update .secrets.baseline

* clear notebook outputs

* remove variable F
@BabyCNM BabyCNM enabled auto-merge February 26, 2025 01:54
Copy link
Collaborator

@alecsolder alecsolder left a comment

Choose a reason for hiding this comment

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

Some comments, and I think I spotted a bug elsewhere

@giorgossideris
Copy link
Collaborator

Some comments, and I think I spotted a bug elsewhere

Hello @alecsolder thank you for your detailed review! Before handling the proposed changes I would like to verify that this approach is the way to go. As I mentioned in the #755 another way to address this issue would be to modify the input of _beam_reply and _mtcs_reply to accept messages instead of prompt, which might result in a cleaner solution.

However, there may be a specific reason behind the current structuring of the arguments, so I’d love to hear your thoughts on this (@alecsolder, @BabyCNM, @Hk669).

If you consider that the current approach is preferable, I will work on the proposed changes!

@BabyCNM
Copy link
Collaborator Author

BabyCNM commented Feb 27, 2025

@giorgossideris Thanks for your prompt reply! Your branch is protected, so I can’t modify your code directly. As a result, I had to create a separate branch and PR. In the future, you can enable the “Allow edits by maintainers” option when creating a PR, which would allow us to make direct modifications to your code.

Regarding where to store the chat history, the prompt variable in functions like mcts_reply is a suitable place. However, it requires concatenating all messages into a single string rather than passing a list (messages). Otherwise, some LLMs might misinterpret the chat history as “few-shot examples” and ignore the system message (e.g., instructions to provide options or evaluate choices).

I prefer your approach because it condenses the chat history efficiently, reducing token usage for some LLMs (though the savings are minimal for OpenAI models since cached tokens are inexpensive). Additionally, it helps summarize key reasoning from previous steps. Please proceed with any reasonable changes you find necessary, and feel free to ignore or resolve comments that are not applicable.

Thanks again!

@davorrunje
Copy link
Collaborator

@giorgossideris could you please reply and/or resolve comments made by @alecsolder above?

@giorgossideris
Copy link
Collaborator

@giorgossideris could you please reply and/or resolve comments made by @alecsolder above?

Yes, I will do so today.

@giorgossideris
Copy link
Collaborator

giorgossideris commented Feb 27, 2025

@davorrunje I opened a PR to resolve the remained comments.

This rewriting: 1) generalizes 'STEPS ALREADY EXECUTED' to 'ACTIVITY LOG', and 2) generalizes 'current/last question asked by the user' to 'current/last question to be addressed'
…g-prompt-ag2

[comments handling] Add prompt rewriting for multiple messages in ReasoningAgent
@BabyCNM BabyCNM added this pull request to the merge queue Feb 28, 2025
Merged via the queue into main with commit a46221c Feb 28, 2025
17 checks passed
@BabyCNM BabyCNM deleted the reasoning-agent-rewriting-prompt-ag2 branch February 28, 2025 04:14
Copy link

codecov bot commented Feb 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

see 39 files with indirect coverage changes

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.

5 participants