-
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
469 missing information in ipfsagentresult #521
Conversation
…ing-information-in-ipfsagentresult # Conflicts: # prediction_market_agent_tooling/deploy/agent.py
reasoning = ( | ||
processed_market.answer.reasoning | ||
if processed_market.answer.reasoning | ||
else "" | ||
) | ||
agent_result = IPFSAgentResult(reasoning=reasoning, agent_name=self.agent_name) |
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 moved this logic from OmenAgentMarket -> DeployableTraderAgent because the property agent_name
belongs to DeployableTraderAgent
.
One could simply pass the property as arg, but I would argue that the responsibility to build a IPFSAgentResult should be handled by the agent itself.
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.
IPFSAgentResult
is specific to Omen; for example, Metaculus wants only a comment without any IPFS upload.
That refactoring was made based on Evan's comment because there were a lot of Omen-uniquess in the DeployableTraderAgent.
Maybe it could be named IPFSOmenAgentResult
or something to make it clearer in the code. 🤔
Wdyt just passing agent_name
into store_prediction
?
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.
No strong preference here - passing agent_name
is fine
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.
Maybe it could be named IPFSOmenAgentResult or something to make it clearer in the code. 🤔
I would prefer to keep it as IPFSAgentResult
- we can rename it once we have other agents uploading results as well.
Co-authored-by: Peter Jung <[email protected]>
WalkthroughThe pull request introduces several modifications across multiple files, primarily focusing on enhancing the Changes
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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 (
|
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: 2
🧹 Outside diff range and nitpick comments (2)
prediction_market_agent_tooling/markets/agent_market.py (1)
232-235
: LGTM: Method signature updated correctly.The
store_prediction
method signature has been appropriately updated to include theagent_result
parameter. This change aligns with the PR objectives and maintains the abstract nature of the method.Consider updating the method's docstring to reflect the new
agent_result
parameter and its purpose.prediction_market_agent_tooling/markets/omen/data_models.py (1)
801-801
: LGTM! Consider reordering fields for better readability.The addition of the
agent_name
field is correct and aligns with the PR objectives. However, for better code organization, consider moving theagent_name
field above themodel_config
. This keeps all the fields together and separates them from the configuration.Here's a suggested reordering:
class IPFSAgentResult(BaseModel): reasoning: str - agent_name: str + agent_name: str model_config = ConfigDict( extra="forbid", )
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (4)
- prediction_market_agent_tooling/deploy/agent.py (3 hunks)
- prediction_market_agent_tooling/markets/agent_market.py (2 hunks)
- prediction_market_agent_tooling/markets/omen/data_models.py (1 hunks)
- prediction_market_agent_tooling/markets/omen/omen.py (1 hunks)
🧰 Additional context used
🔇 Additional comments (4)
prediction_market_agent_tooling/markets/agent_market.py (1)
22-22
: LGTM: New import statement is correctly placed and follows best practices.The import of
IPFSAgentResult
from the Omen-specific module is appropriate and aligns with the PR objectives.prediction_market_agent_tooling/markets/omen/omen.py (1)
Line range hint
420-438
: LGTM! The changes improve thestore_prediction
method.The updated implementation correctly incorporates the
agent_result
parameter, which now includes theagent_name
as mentioned in the PR objectives. The code is more streamlined by directly using theagent_result
in thestore_agent_result
call, avoiding unnecessary object creation.prediction_market_agent_tooling/deploy/agent.py (2)
338-340
: Addition ofagent_name
property enhances metadata handlingThe
agent_name
property provides a standardized way to access the agent's class name, improving metadata consistency across different agents.
500-508
:⚠️ Potential issueRefactor to remove Omen-specific logic from
DeployableTraderAgent
Creating an
IPFSAgentResult
and using it inafter_process_market
introduces Omen-specific functionality intoDeployableTraderAgent
. This violates the separation of concerns and reduces the agent's applicability to other markets that do not use IPFS, such as Metaculus.As previously suggested, consider the following refactoring:
- Pass
agent_name
as an argument tostore_prediction
, allowing market-specific implementations to handle the result appropriately.- Define an abstract method or hook in
DeployableTraderAgent
for result handling that can be overridden by subclasses or specific market implementations.- Move the creation of
IPFSAgentResult
into the Omen-specific market class to maintain a clean separation between generic agent logic and market-specific details.
…ing-information-in-ipfsagentresult # Conflicts: # prediction_market_agent_tooling/deploy/agent.py # prediction_market_agent_tooling/markets/agent_market.py # prediction_market_agent_tooling/markets/omen/omen.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: 2
🧹 Outside diff range and nitpick comments (1)
prediction_market_agent_tooling/markets/agent_market.py (1)
234-248
: LGTM! The changes follow good interface design principles.The addition of
agent_name
parameter to both storage methods follows good Object-Oriented design principles:
- The interface is clearly defined in the base class
- The changes are consistent with the PR objective of adding agent_name to IPFS structure
- The abstract methods ensure that all subclasses must implement the new parameter
Consider documenting the purpose of the
agent_name
parameter in the method docstrings to help implementers understand its significance in the IPFS storage context.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (4)
prediction_market_agent_tooling/deploy/agent.py
(5 hunks)prediction_market_agent_tooling/markets/agent_market.py
(1 hunks)prediction_market_agent_tooling/markets/metaculus/metaculus.py
(1 hunks)prediction_market_agent_tooling/markets/omen/omen.py
(4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- prediction_market_agent_tooling/deploy/agent.py
🔇 Additional comments (5)
prediction_market_agent_tooling/markets/metaculus/metaculus.py (1)
110-110
: Verify IPFS storage implementation for agent_name
.
The agent_name
parameter has been added but is not utilized in the method implementation. Based on the PR objectives, this parameter is intended for IPFS storage, but the current implementation only handles Metaculus platform interactions.
Let's verify if IPFS storage is implemented in parent classes or related files:
Would you like assistance in implementing the IPFS storage logic for the agent_name
parameter?
✅ Verification successful
Let me try another search strategy to verify the IPFS implementation.
Based on the search results, I can now generate the final response:
The agent_name
parameter is correctly implemented as part of the interface
The agent_name
parameter is part of the abstract store_prediction
method defined in the base AgentMarket
class, which all market implementations must follow. The Metaculus implementation inherits this interface requirement. While the parameter is currently unused in the Metaculus implementation, this is acceptable as:
- The base class defines it as a required parameter for consistency across all market implementations
- The Metaculus platform specifically only requires predictions and comments, with no IPFS integration
- Other market implementations (like Omen) can utilize this parameter as needed
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for IPFS storage implementation in related files
# Test 1: Search for IPFS-related storage implementations
echo "Searching for IPFS storage implementations..."
rg -l "ipfs|IPFS" --type python
# Test 2: Check parent class implementation
echo "Checking AgentMarket implementation..."
ast-grep --pattern 'class AgentMarket:
$$$
store_prediction($$$) {
$$$
}
$$$
'
Length of output: 345
Script:
#!/bin/bash
# Search for IPFS-related code and agent_name usage
echo "Searching for IPFS and agent_name usage..."
rg -A 5 "agent_name.*ipfs|ipfs.*agent_name" .
# Search for store_prediction implementations
echo "Searching for store_prediction implementations..."
rg -A 10 "def store_prediction" .
# Check base class implementation
echo "Looking for base class AgentMarket..."
rg -A 20 "class AgentMarket" .
Length of output: 5370
prediction_market_agent_tooling/markets/omen/omen.py (4)
416-417
: LGTM! Correctly using public_key for operational balance check.
The implementation correctly uses the EOA wallet's public key to verify operational balance, as transaction costs are paid from this wallet.
422-424
: LGTM! Method signature updated correctly.
The addition of agent_name
parameter aligns with the PR objective, and the empty implementation is correct as predictions are stored along with trades.
Line range hint 427-444
: LGTM! Proper implementation of agent_name storage.
The method correctly incorporates the new agent_name
parameter in the IPFS storage process, with proper error handling and logging.
Line range hint 1244-1274
: LGTM! Enhanced logging and trade retrieval.
The changes improve logging clarity and ensure proper trade retrieval with correct market identification and time constraints.
…ing-information-in-ipfsagentresult
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: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
prediction_market_agent_tooling/deploy/agent.py
(5 hunks)
🔇 Additional comments (3)
prediction_market_agent_tooling/deploy/agent.py (3)
156-159
: LGTM: Improved Langfuse trace parameter handling
The changes enhance readability and maintain consistent session tracking across trace updates.
482-484
: Related to previous issue about unused parameter
623-631
: Related to previous issue about unused parameter
agent_name: str, | ||
) -> None: | ||
keys = APIKeys() | ||
if self.store_prediction: | ||
market.store_prediction(processed_market=processed_market, keys=keys) | ||
market.store_prediction( | ||
processed_market=processed_market, keys=keys, agent_name=self.agent_name | ||
) |
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.
Remove unused parameter agent_name
The method accepts agent_name
parameter but uses self.agent_name
instead. Either remove the unused parameter or use the passed value.
def after_process_market(
self,
market_type: MarketType,
market: AgentMarket,
processed_market: ProcessedMarket | None,
- agent_name: str,
) -> None:
keys = APIKeys()
if self.store_prediction:
market.store_prediction(
processed_market=processed_market, keys=keys, agent_name=self.agent_name
)
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
agent_name: str, | |
) -> None: | |
keys = APIKeys() | |
if self.store_prediction: | |
market.store_prediction(processed_market=processed_market, keys=keys) | |
market.store_prediction( | |
processed_market=processed_market, keys=keys, agent_name=self.agent_name | |
) | |
def after_process_market( | |
self, | |
market_type: MarketType, | |
market: AgentMarket, | |
processed_market: ProcessedMarket | None, | |
) -> None: | |
keys = APIKeys() | |
if self.store_prediction: | |
market.store_prediction( | |
processed_market=processed_market, keys=keys, agent_name=self.agent_name | |
) |
@property | ||
def agent_name(self) -> str: | ||
return self.__class__.__name__ | ||
|
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.
🛠️ Refactor suggestion
Consider making agent_name more configurable
While the current implementation works, consider making it more flexible by allowing subclasses to customize their agent name, either through constructor parameter or class attribute.
- @property
- def agent_name(self) -> str:
- return self.__class__.__name__
+ def __init__(
+ self,
+ enable_langfuse: bool = APIKeys().default_enable_langfuse,
+ store_prediction: bool = True,
+ agent_name: str | None = None,
+ ) -> None:
+ super().__init__(enable_langfuse=enable_langfuse)
+ self.store_prediction = store_prediction
+ self._agent_name = agent_name
+
+ @property
+ def agent_name(self) -> str:
+ return self._agent_name or self.__class__.__name__
Committable suggestion skipped: line range outside the PR's diff.
-> Adding agent_name to structure being uploaded to IPFS