feat: Add comprehensive toolkit instructions and improve agent prompts

- Create detailed markdown instructions for all toolkits:
  * market_instructions.md: 6 tools with VWAP aggregation, selection strategies
  * news_instructions.md: 4 tools with sentiment analysis guidelines
  * social_instructions.md: 2 tools with platform-specific notes
  * plan_memory_instructions.md: 4 tools with workflow patterns and best practices
  * symbols_instructions.md: 2 tools with symbol resolution and search

- Update all toolkit classes to load instructions from external .md files:
  * MarketAPIsTool, NewsAPIsTool, SocialAPIsTool
  * PlanMemoryTool (moved from agents to api/tools)
  * CryptoSymbolsTools

- Enhance agent prompts with detailed tool usage guidance:
  * team_market.md: Expanded tool descriptions, asset conversion, time ranges
  * team_news.md: Added query formulation, limit guidelines, error handling
  * team_social.md: Platform-specific notes, limit guidelines, content warnings
  * team_leader.md: Added CryptoSymbolsTools integration, detailed workflow steps

- Fix market data aggregation:
  * aggregate_multi_assets now calculates total volume (sum) instead of average
  * Implement currency filtering (prefer USD when currencies differ)
  * Refactor aggregate_multi_assets to call aggregate_single_asset for DRY

- Update test expectations for volume calculations

All toolkits now follow unified structure with external markdown documentation
This commit is contained in:
Simone Garau
2025-10-30 16:22:21 +01:00
parent 0a69dcbace
commit a47ce46ea9
15 changed files with 1195 additions and 59 deletions

View File

@@ -1,3 +1,4 @@
from pathlib import Path
from agno.tools import Toolkit
from app.api.wrapper_handler import WrapperHandler
from app.api.core.news import NewsWrapper, Article
@@ -15,6 +16,17 @@ class NewsAPIsTool(NewsWrapper, Toolkit):
If no wrapper succeeds, an exception is raised.
"""
@staticmethod
def _load_instructions() -> str:
"""
Load the toolkit instructions from the external text file.
Returns:
str: The content of the instructions file.
"""
instructions_path = Path(__file__).parent / "instructions" / "news_instructions.md"
return instructions_path.read_text(encoding="utf-8")
def __init__(self):
"""
Initialize the NewsAPIsTool with news API wrappers configured in configs.yaml.
@@ -38,6 +50,7 @@ class NewsAPIsTool(NewsWrapper, Toolkit):
self.get_top_headlines_aggregated,
self.get_latest_news_aggregated,
],
instructions=self._load_instructions(),
)
def get_top_headlines(self, limit: int = 100) -> list[Article]: