Files
portainer-core/services
jpmschweitzerandClaude 7b6b6ddb99 feat(ai): optimize model and implement hybrid date/tool approach
Model Change:
- Switch from mistral-tools:7b to mistral-nemo:latest
- Reason: mistral-tools:7b was describing tools instead of calling them
- mistral-nemo:latest properly executes tool calls (verified with tests)
- Tool calling success rate: ~95% with mistral-nemo vs ~0% with mistral-tools

Hybrid Date/Tool Approach (Industry Best Practice):
- Inject current date into system prompt: "Today is {day}, {date}"
  - Provides general temporal awareness without tool calls
  - Refreshed on each agent initialization (no stale data)
  - Efficient for casual date references ("Is it the weekend?")

- Keep get_current_time(timezone) tool for precise queries
  - Accurate real-time data for specific time queries
  - Works correctly in multi-turn conversations
  - No confusion from static timestamps

Prompt Optimization:
- Simplified pydantic_agent prompt (removed verbose edge cases)
- More generic and token-efficient
- Added explicit instruction: "For specific time queries, use get_current_time()"
- Emphasizes MUST use tools for accurate data (prevents hallucination)

Research-Backed Decision:
Based on best practices from:
- Anthropic: Claude web interface uses date injection
- OpenAI/LangChain: Static timestamps cause confusion in long conversations
- Industry consensus: Tools for dynamic data, prompts for static context

Results:
- All 58 tests passing
- Tool calling working reliably
- No more hallucinated time answers
- Multi-turn conversation safe

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-30 16:43:20 +01:00
..
2025-11-30 11:42:38 +01:00