-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add GoalManager, and make a DeployableMicrochainAgent with this feature #413
Conversation
Warning Rate limit exceeded@evangriffiths has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 10 minutes and 24 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThe updates introduce a Changes
Assessment against linked issues
Possibly related issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
TODO add the ability to continue from a previous session if the goal | ||
is not complete. |
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.
TODO support generation of long-horizon goals with a specified | ||
completion date, until which the goal's status is 'pending'. |
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.
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.
Actionable comments posted: 4
Outside diff range, codebase verification and nitpick comments (3)
prediction_market_agent/db/evaluated_goal_table_handler.py (2)
24-34
: Clarify type hint forget_latest_evaluated_goals
.The return type hint
list[EvaluatedGoalModel]
might be misleading if the method can return an empty list. Consider specifying that an empty list is possible.def get_latest_evaluated_goals(self, limit: int) -> list[EvaluatedGoalModel]: ...
36-43
: Improve docstring clarity.The docstring for
delete_all_evaluated_goals
could be more descriptive. Consider specifying that it deletes goals for the givenagent_id
.""" Delete all evaluated goals associated with the specified `agent_id`. """scripts/delete_agent_db_entries.py (1)
Line range hint
17-44
: Update docstring to reflect new functionality.The docstring for the
main
function should be updated to include the newdelete_goals
parameter and its purpose.""" Delete all memories, prompts, and evaluated goals for a given agent, defined by the session_id. """
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (2)
poetry.lock
is excluded by!**/*.lock
,!**/*.lock
pyproject.toml
is excluded by!**/*.toml
Files selected for processing (12)
- prediction_market_agent/agents/goal_manager.py (1 hunks)
- prediction_market_agent/agents/microchain_agent/deploy.py (5 hunks)
- prediction_market_agent/agents/microchain_agent/memory.py (2 hunks)
- prediction_market_agent/agents/microchain_agent/microchain_agent.py (2 hunks)
- prediction_market_agent/agents/utils.py (1 hunks)
- prediction_market_agent/db/evaluated_goal_table_handler.py (1 hunks)
- prediction_market_agent/db/models.py (1 hunks)
- prediction_market_agent/run_agent.py (3 hunks)
- scripts/delete_agent_db_entries.py (3 hunks)
- tests/agents/test_goal_manager.py (1 hunks)
- tests/db/test_evaluated_goal_table_handler.py (1 hunks)
- tests/test_chat_history.py (2 hunks)
Additional context used
Ruff
tests/agents/test_goal_manager.py
152-152: Local variable
assistant_message
is assigned to but never usedRemove assignment to unused variable
assistant_message
(F841)
205-205: Comparison to
None
should becond is None
Replace with
cond is None
(E711)
278-278: Comparison to
None
should becond is None
Replace with
cond is None
(E711)
prediction_market_agent/agents/goal_manager.py
203-211: Return the condition directly
Inline condition
(SIM103)
Additional comments not posted (28)
prediction_market_agent/db/evaluated_goal_table_handler.py (1)
9-19
: Ensure SQLHandler initialization is correct.The
EvaluatedGoalTableHandler
class initializes aSQLHandler
with a model and optional database URL. Ensure that theSQLHandler
is correctly handling the model and URL, especially if the URL can beNone
.Verify that the
SQLHandler
can handle aNone
value forsqlalchemy_db_url
without issues.prediction_market_agent/db/models.py (1)
34-50
: Ensure field types align with database schema.The
EvaluatedGoalModel
class defines fields with specific types. Ensure that these types align with the database schema and that fields likedatetime_
are correctly indexed if needed for performance.Verify that the database schema supports these field types and consider indexing
datetime_
for efficient queries.scripts/delete_agent_db_entries.py (1)
38-44
: Ensure exception handling is robust.The logic for deleting evaluated goals raises an exception if entries are not deleted. Ensure that this exception handling is robust and provides meaningful error messages.
Verify that the exception handling provides clear and actionable error messages to aid in debugging.
tests/test_chat_history.py (1)
80-89
: Good addition: Test for stringified chat history.The test function
test_stringified_chat_history
correctly validates the string representation of aChatHistory
object. This enhances test coverage for the chat history functionality.tests/db/test_evaluated_goal_table_handler.py (4)
14-21
: Well-structured fixture for table handler setup.The
table_handler
fixture correctly sets up an in-memory SQLite DB for testing. This is a good practice for isolated and repeatable tests.
24-40
: Comprehensive test for saving and loading evaluated goals.The
test_save_load_evaluated_goal_0
function effectively tests the saving and loading of an evaluated goal, ensuring data integrity.
43-81
: Effective test for LIFO order and multiple goal saving/loading.The
test_save_load_evaluated_goal_1
function correctly verifies the LIFO order and the ability to handle multiple goals. The use of different limits enhances the test robustness.
84-114
: Appropriate test for handling multiple agents.The
test_save_load_evaluated_goal_multiple_agents
function ensures that goals are correctly associated with different agents, which is crucial for multi-agent scenarios.prediction_market_agent/run_agent.py (1)
28-28
: Seamless integration of new agent type.The addition of
DeployableMicrochainWithGoalManagerAgent0
to theRunnableAgent
enum andRUNNABLE_AGENTS
dictionary is well-implemented, enhancing the agent system's capabilities.Also applies to: 59-59, 80-80
prediction_market_agent/agents/utils.py (1)
32-32
: Addition ofMICROCHAIN_AGENT_OMEN_WITH_GOAL_MANAGER
is approved.The new enumeration value extends the capabilities of the
AgentIdentifier
class without affecting existing logic.prediction_market_agent/agents/microchain_agent/memory.py (2)
26-28
: Addition of__str__
method inChatMessage
is approved.The method enhances readability by providing a formatted string representation of the message.
104-106
: Addition of__str__
method inChatHistory
is approved.The method provides a clear overview of chat messages, improving debugging and logging.
prediction_market_agent/agents/microchain_agent/deploy.py (5)
5-5
: Import ofGoalManager
is approved.The import is necessary for integrating goal management features.
36-36
: Introduction ofgoal_manager
attribute is approved.The optional
goal_manager
attribute allows the agent to manage and evaluate goals, enhancing its functionality.
57-61
: Conditional logic forgoal_manager
is approved.The logic checks for the presence of a
goal_manager
and retrieves the current goal if available, enhancing the agent's capabilities.
81-92
: Goal evaluation and history update logic is approved.The logic evaluates the goal's progress and appends the evaluation to the agent's history, improving its operational capabilities.
136-152
: Addition ofDeployableMicrochainWithGoalManagerAgent0
is approved.The new class integrates goal management features, enhancing the agent's decision-making and performance in trading tasks.
prediction_market_agent/agents/microchain_agent/microchain_agent.py (2)
207-208
: LGTM!The addition of the
prompt
parameter instep_end_callback
is consistent with its usage inbuild_agent
.
150-150
: LGTM! Verify the usage of theprompt
parameter.The addition of the
prompt
parameter enhances the agent's flexibility.Ensure that the
prompt
parameter is correctly utilized throughout the codebase.Run the following script to verify the usage of the
prompt
parameter:Also applies to: 207-208
Verification successful
The
prompt
parameter is correctly utilized throughout the codebase.The
prompt
parameter is consistently used in various parts of the codebase, including agent initialization and prompt handling functionalities. No issues were found with its integration.
- The
prompt
parameter is used in thebuild_agent
function to set theagent.prompt
.- It is referenced in test files and other scripts related to prompt handling.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the `prompt` parameter in the codebase. # Test: Search for occurrences of the `prompt` parameter. Expect: Consistent usage. rg --type python -A 5 $'prompt'Length of output: 61
Script:
#!/bin/bash # Description: Verify the usage of the `prompt` parameter in the codebase. # Test: Search for occurrences of the `prompt` parameter. Expect: Consistent usage. rg --type py -A 5 $'prompt'Length of output: 96659
tests/agents/test_goal_manager.py (6)
12-61
: Comprehensive test for retry limit functionality.The test effectively covers various scenarios for the retry limit in
GoalManager
.
64-100
: Effective test for evaluated goals string conversion.The test correctly verifies the string representation of evaluated goals.
103-132
: Comprehensive test for goal generation.The test effectively covers different scenarios for goal generation in
GoalManager
.
135-147
: Effective test for chat history retrieval after goal prompt.The test correctly verifies the retrieval of chat history after a goal prompt.
150-163
: Effective test for error handling in chat history retrieval.The test correctly verifies the error handling when the goal prompt is not found in the chat history.
Tools
Ruff
152-152: Local variable
assistant_message
is assigned to but never usedRemove assignment to unused variable
assistant_message
(F841)
208-244
: Effective test for evaluating completed goals with output.The test correctly verifies the evaluation of a completed goal with output.
prediction_market_agent/agents/goal_manager.py (3)
51-65
: Well-definedGoal
class.The class effectively encapsulates a goal's attributes and provides a method to convert it to a prompt.
68-83
: Well-definedGoalEvaluation
class.The class effectively encapsulates a goal evaluation's attributes and provides a method to convert it to a string.
86-129
: Well-definedEvaluatedGoal
class.The class effectively extends
Goal
with additional attributes and provides methods for conversion to/from a model and to a goal.
high_level_description="You are a trader agent in prediction markets to maximise your profit.", | ||
agent_capabilities=( | ||
"You are able to:" | ||
"\n- List all binary markets that can be traded." | ||
"\n- List the current outcome probabilities for each open market." | ||
"\n- Predict the outcome probability for a market." | ||
"\n- Buy, sell and hold outcome tokens in a market." | ||
"\n- Query your wallet balance, and the positions you hold in open markets." | ||
"\n- Query the past bets you've made, and their outcomes." | ||
), |
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'm not super-keen on how the high_level_description
and agent_capabilities
are defined here. It feels like some duplication of the system prompt, and engine.help
respectively. But I couldn't think of a better way of doing this
high_level_description
is different enough from the system prompt, and I didn't think it was a good solution to try and derive it from the system prompt via an llm callagent_capabilities
could be derived fromagent.engine.functions
, but there would be some messiness if I tried to define this afterbuild_agent_functions
is called.
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.
This is good enough, but maybe you can use (as you mentioned) agent.engine.functions
(or agent.help
) to get a long list of functions, and have an LLM generate a summary of those and output a bullet-point list?
At least you stay up-to-date with the most recent functions.
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.
Done 😃
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.
Actionable comments posted: 3
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- tests/agents/test_goal_manager.py (1 hunks)
Additional context used
Ruff
tests/agents/test_goal_manager.py
155-155: Local variable
assistant_message
is assigned to but never usedRemove assignment to unused variable
assistant_message
(F841)
209-209: Comparison to
None
should becond is None
Replace with
cond is None
(E711)
284-284: Comparison to
None
should becond is None
Replace with
cond is None
(E711)
Additional comments not posted (5)
tests/agents/test_goal_manager.py (5)
14-63
: LGTM! Effective test for retry limit functionality.The test cases cover various scenarios for retry limits effectively.
66-102
: LGTM! Effective test for string conversion of evaluated goals.The test verifies the output string format correctly.
105-135
: LGTM! Effective test for goal generation.The test cases effectively verify the goal generation logic, considering previous evaluated goals.
153-166
: LGTM! Effective test for error handling in chat history retrieval.The test correctly verifies the error handling logic.
Tools
Ruff
155-155: Local variable
assistant_message
is assigned to but never usedRemove assignment to unused variable
assistant_message
(F841)
212-249
: LGTM! Effective test for evaluating completed goals with output.The test correctly verifies the evaluation logic for a completed goal with output.
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- prediction_market_agent/agents/goal_manager.py (1 hunks)
- tests/agents/test_goal_manager.py (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- prediction_market_agent/agents/goal_manager.py
Additional comments not posted (8)
tests/agents/test_goal_manager.py (8)
14-64
: Comprehensive test for retry limit logic.The test cases effectively cover various scenarios for the retry limit in
GoalManager
.
67-103
: Effective test for evaluated goals string conversion.The test correctly verifies the string representation of evaluated goals.
106-136
: Thorough test for goal generation logic.The test effectively verifies the goal generation based on previous evaluations.
139-151
: Effective test for chat history retrieval.The test correctly verifies the retrieval of chat history after a goal prompt.
154-166
: Correct test for error handling in chat history retrieval.The test appropriately raises and checks a ValueError when the goal prompt is not found.
169-209
: Effective test for evaluating completed goals withNone
output.The test correctly verifies the evaluation of a completed goal with a
None
output.
212-249
: Effective test for evaluating completed goals with non-None
output.The test correctly verifies the evaluation of a completed goal with specific output content.
252-284
: Effective test for evaluating incomplete goals.The test correctly verifies the evaluation of an incomplete 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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- prediction_market_agent/agents/goal_manager.py (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- prediction_market_agent/agents/goal_manager.py
Additional context used
Learnings (1)
Common learnings
Learnt from: evangriffiths PR: gnosis/prediction-market-agent#413 File: prediction_market_agent/db/evaluated_goal_table_handler.py:21-22 Timestamp: 2024-08-22T12:57:57.324Z Learning: The current use case for the `GoalManager` involves generating only one goal per session, so batch saving is not needed at the moment, but it may be considered for future use.
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (2)
poetry.lock
is excluded by!**/*.lock
,!**/*.lock
pyproject.toml
is excluded by!**/*.toml
Files selected for processing (1)
- prediction_market_agent/agents/microchain_agent/deploy.py (6 hunks)
Files skipped from review as they are similar to previous changes (1)
- prediction_market_agent/agents/microchain_agent/deploy.py
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- prediction_market_agent/run_agent.py (3 hunks)
Files skipped from review as they are similar to previous changes (1)
- prediction_market_agent/run_agent.py
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.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (1)
prediction_market_agent/agents/microchain_agent/deploy.py (1)
40-44
: Clarify the purpose of thebuild_goal_manager
method.This method currently returns
None
, which suggests it's intended to be overridden in subclasses. Consider adding a docstring to clarify its purpose and usage.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (2)
poetry.lock
is excluded by!**/*.lock
,!**/*.lock
pyproject.toml
is excluded by!**/*.toml
Files selected for processing (2)
- prediction_market_agent/agents/microchain_agent/deploy.py (6 hunks)
- prediction_market_agent/agents/microchain_agent/microchain_agent.py (1 hunks)
Additional comments not posted (3)
prediction_market_agent/agents/microchain_agent/deploy.py (2)
153-162
: Ensure correct initialization ofGoalManager
.The
build_goal_manager
method properly initializes theGoalManager
with specific parameters. Verify that theagent_capabilities
are dynamically generated and accurate. Consider adding error handling for potential issues during initialization.Consider adding error handling to manage potential initialization failures, enhancing robustness.
Verification successful
Dynamic generation of
agent_capabilities
is correctly implemented.The
get_functions_summary_list
function dynamically generates theagent_capabilities
by summarizing the functions available to the agent. Consider adding error handling in thebuild_goal_manager
method to manage potential initialization failures, enhancing robustness.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the dynamic generation of `agent_capabilities`. # Test: Search for the implementation of `get_functions_summary_list` to ensure it dynamically generates capabilities. rg --type python -A 5 $'get_functions_summary_list'Length of output: 81
Script:
#!/bin/bash # Description: Verify the dynamic generation of `agent_capabilities`. # Corrected Test: Search for the implementation of `get_functions_summary_list` to ensure it dynamically generates capabilities. rg --type py -A 5 $'get_functions_summary_list'Length of output: 1210
Line range hint
77-105
: Review the integration ofGoalManager
in therun
method.The logic correctly checks for the presence of a
goal_manager
and handles goal retrieval and evaluation. However, ensure that thegoal_manager
is robustly integrated and tested, especially in scenarios where it might beNone
.Would you like me to help with creating unit tests for this integration?
prediction_market_agent/agents/microchain_agent/microchain_agent.py (1)
248-249
: Review the implementation ofget_functions_summary_list
.The function correctly generates a summary list of functions. Ensure that the function list is always correctly populated and consider adding error handling for cases where the function list might be empty or malformed.
Add error handling to manage cases where the input list is empty or contains invalid data, improving robustness.
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- prediction_market_agent/agents/microchain_agent/deploy.py (6 hunks)
- prediction_market_agent/agents/microchain_agent/microchain_agent.py (1 hunks)
Files skipped from review as they are similar to previous changes (2)
- prediction_market_agent/agents/microchain_agent/deploy.py
- prediction_market_agent/agents/microchain_agent/microchain_agent.py
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- prediction_market_agent/agents/microchain_agent/deploy.py (6 hunks)
- prediction_market_agent/agents/microchain_agent/prompts.py (4 hunks)
Additional comments not posted (6)
prediction_market_agent/agents/microchain_agent/prompts.py (3)
41-50
: New minimal system prompt added successfully.The
TRADING_AGENT_SYSTEM_PROMPT_MINIMAL
is well-defined and aligns with the intended use of providing a minimalistic approach for the trading agent. This allows for greater flexibility in scenarios where user-provided instructions will guide the agent's actions.The addition of this new prompt is approved.
93-93
: Enum updated to include new minimal prompt choice.The addition of
TRADING_AGENT_MINIMAL
to theSystemPromptChoice
enum is a necessary update to support the new minimal trading agent prompt. This change ensures that the system can properly recognize and handle different types of prompts based on the agent's operational context.The update to the enum is approved.
115-118
: Integration of new prompt into system configurations.The updates to the
FunctionsConfig
class and theSYSTEM_PROMPTS
dictionary are well-executed. These changes ensure that the new minimal prompt is fully integrated into the system, allowing the agent to utilize this prompt effectively during its operations.The updates to the system configurations are approved.
Also applies to: 136-136
prediction_market_agent/agents/microchain_agent/deploy.py (3)
40-44
: Base implementation ofbuild_goal_manager
method.The method
build_goal_manager
inDeployableMicrochainAgent
is designed to returnNone
by default, which is a sensible default that allows derived classes to override this method based on their specific needs. This design supports flexibility and extensibility in how goal management is integrated into different agents.The base implementation of this method is approved.
154-163
: Robust integration ofGoalManager
in new agent class.The method
build_goal_manager
inDeployableMicrochainWithGoalManagerAgent0
is effectively implemented to return aGoalManager
instance configured with specific capabilities and a retry limit. This setup aligns well with the PR objectives of enhancing the agent's functionality through structured goal management.The integration of
GoalManager
in this new agent class is approved.
Line range hint
77-106
: Comprehensive goal management logic inrun
method.The goal management logic in the
run
method ofDeployableMicrochainAgent
is well-implemented. It includes checks for the presence of agoal_manager
, retrieves the current goal, and handles goal evaluation and saving. This comprehensive approach ensures that the agent can effectively manage and report on its goals, aligning with the PR objectives.The implementation of goal management logic in the
run
method is approved.
) | ||
latest_evaluated_goals_str = self.evaluated_goals_to_str(latest_evaluated_goals) | ||
llm = ChatOpenAI( | ||
temperature=0, |
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.
This might be better with super low temperature constant I introduced somewhere, if you want consistency as much as possible
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 still don't feel totally convinced by the "very small temperature is best for consistency" argument (I guess the same point expressed in the comment thread on the original PR https://github.com/gnosis/prediction-market-agent-tooling/pull/307/files#r1675590362).
I re-googled to see if there was any new info, and haven't found anything to convince one way or the other. In the anthropic API docs (https://docs.anthropic.com/en/api/complete) it says:
Defaults to 1.0. Ranges from 0.0 to 1.0. Use temperature closer to 0.0 for analytical / multiple choice, and closer to 1.0 for creative and generative tasks.
Note that even with temperature of 0.0, the results will not be fully deterministic.
which suggests 0.0 is more consistent than 0.000001, but still too vague to be sure!
Anyway, all that to say, if it's alright with you I'll stick with 0.0 until we know more (and we just have inconsistent code 😅)
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.
Sounds good! I'm now curious to do some manual experiment about this 🙈 Maybe Friday afternoon mini project 😄
@@ -60,6 +74,10 @@ def run( | |||
), | |||
) | |||
|
|||
if goal_manager := self.build_goal_manager(agent=agent): | |||
goal = goal_manager.get_goal() | |||
agent.prompt = goal.to_prompt() if goal else None |
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.
Isn't the goal undefined if the if statement above is evaluated as false?
agent.prompt = goal.to_prompt() if goal else None | |
agent.prompt = goal.to_prompt() if goal else None |
(not sure if that's the right fix 😄 )
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.
Ah eagle eye'd spot, thanks!
Since GoalManager.get_goal
always returns a goal, it can be a little simpler:
if goal_manager := self.build_goal_manager(agent=agent):
goal = goal_manager.get_goal()
agent.prompt = goal.to_prompt()
def build_goal_manager( | ||
self, | ||
agent: Agent, | ||
) -> GoalManager | None: |
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.
) -> GoalManager | None: | |
) -> GoalManager: |
@@ -29,6 +29,7 @@ class AgentIdentifier(str, Enum): | |||
MICROCHAIN_AGENT_OMEN_LEARNING_2 = "general-agent-2" | |||
MICROCHAIN_AGENT_OMEN_LEARNING_3 = "general-agent-3" | |||
MICROCHAIN_AGENT_STREAMLIT = "microchain-streamlit-app" | |||
MICROCHAIN_AGENT_OMEN_WITH_GOAL_MANAGER = "general-agent-4-with-goal-manager" |
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.
MICROCHAIN_AGENT_OMEN_WITH_GOAL_MANAGER = "general-agent-4-with-goal-manager" | |
MICROCHAIN_AGENT_OMEN_WITH_GOAL_MANAGER = "trader-agent-4-with-goal-manager" |
general agents above are the ones that are learning, this one (based on trader prompt) should be only trader, if that's right, can we distinguish it?
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.
Ah true. How about trader-agent-0-with-goal-manager
, as there are no other trader-agent-*
s in the list?
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.
Sure!
Co-authored-by: Peter Jung <[email protected]>
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
pyproject.toml
is excluded by!**/*.toml
Files selected for processing (2)
- prediction_market_agent/agents/microchain_agent/prompts.py (4 hunks)
- prediction_market_agent/run_agent.py (3 hunks)
Files skipped from review as they are similar to previous changes (2)
- prediction_market_agent/agents/microchain_agent/prompts.py
- prediction_market_agent/run_agent.py
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (2)
poetry.lock
is excluded by!**/*.lock
,!**/*.lock
pyproject.toml
is excluded by!**/*.toml
Files selected for processing (2)
- prediction_market_agent/agents/microchain_agent/deploy.py (6 hunks)
- prediction_market_agent/run_agent.py (3 hunks)
Files skipped from review as they are similar to previous changes (2)
- prediction_market_agent/agents/microchain_agent/deploy.py
- prediction_market_agent/run_agent.py
The
GoalManager
is a way of generating and evaluating goals for an agent. It can be used as a mechanism to learn from its experience, and add more structure to each session.The motivation is that we in theory have a way for the agent to learn from its experience, through a combination of
RememberPastActions
+UpdateMySystemPrompt
, but in practice for our deployed agents it's not clear how effective this is.The
Goal
s generated for an agent are lower-level than the description of the agent ("you are a PM trader agent, make money"), but higher-level than individual tools ("buy Yes tokens"). This makes them suited to being proposed+evaluated on a per-session basis, and therefore (hopefully!) gives the agent some signal on how to adapt on a per-session basis.An agent can use the
GoalManager
to:This feature is added to the microchain agent, but is default-off. A new deployable agent (
DeployableMicrochainWithGoalManagerAgent0
) is added for testing out this feature. You can see it in action below:A goal is generated, and used as the user-prompt for the agent
It seems to work quite nicely with the microchain agent without having to tweak any prompting. It reasons that it has completed the goal, and calls
Stop()
to terminate the program. The goal evaluation is appended to the chat history for the user to see.Fixes #233