obsolete readmes and test logs

This commit is contained in:
2025-11-30 11:42:38 +01:00
parent 8487b2a366
commit 7a748a54e7
4 changed files with 0 additions and 646 deletions
@@ -1,237 +0,0 @@
# Comprehensive System Prompt A/B Test Results
Date: 2025-11-24
Model: mistral:7b
Framework: LangGraph ReAct Agent
Total Tests: 30 (6 variants × 5 scenarios)
## Executive Summary
**Winner: v1_verbose and v3_imperative (tied at 87/100)**
All variants fail on simple "What time is it?" queries but succeed on complex multi-step queries. This is a fundamental issue with example-based prompts containing placeholders.
## Methodology
Tests ran without server restarts using the new `system_prompt_override` API parameter. Each variant tested against 5 scenarios:
1. Time Query ("What time is it?")
2. Current News ("What are the top news stories today?")
3. Stock Query ("What stock is trending highest today?")
4. Service Status ("Is jellyfin running?")
5. System Resources ("How much memory is being used?")
## Results Table
| Variant | Tool Calling | No Announce | Avg Time | Score |
|---------|--------------|-------------|----------|-------|
| **v1_verbose** | 4/5 (80%) | 5/5 (100%) | 0.92s | **87/100** |
| v2_concise | 4/5 (80%) | 4/5 (80%) | 1.51s | 80/100 |
| **v3_imperative** | 4/5 (80%) | 5/5 (100%) | 1.26s | **87/100** |
| v4_minimal | 4/5 (80%) | 5/5 (100%) | 2.38s | 87/100 |
| v4_gemini_suggestion | 4/5 (80%) | 4/5 (80%) | 1.77s | 80/100 |
| v6_hybrid | 4/5 (80%) | 4/5 (80%) | 0.68s | 80/100 |
## Detailed Findings
### Time Query Problem (Universal Failure)
**ALL variants fail the simple "What time is it?" test:**
- **v1_verbose**: "Sir, the time is 10:37 AM." (wrong - actual: 15:28)
- **v2_concise**: "Sir, let me check..." (announced tool)
- **v3_imperative**: "Sir, it's currently 10:47 AM." (wrong)
- **v4_minimal**: "My apologies, Sir..." (incomplete)
- **v4_gemini_suggestion**: "Sir, the time is [current_time]." (placeholder)
- **v6_hybrid**: "Sir, the time is [current date and time]." (placeholder)
**Root Cause**: Examples in prompts contain placeholders like "[time details]" or "[current time]". Models mimic this pattern instead of calling tools.
**Verified**:
- Actual time: 15:28 CET
- Tool works correctly (tested directly)
- Complex "today" queries work fine (calls get_current_time then web_search)
### Accuracy Verification
**Jellyfin Status Test** (v6_hybrid):
- Agent response: "Jellyfin is currently offline"
- Actual status: `Up 3 days (healthy)`
- Tool output: Correctly lists "jellyfin" as running
- **Result**: FALSE NEGATIVE - Agent misinterpreted tool results
### Performance Analysis
**Fastest**: v6_hybrid (0.68s avg) and v1_verbose (0.92s)
**Slowest**: v4_minimal (2.38s avg) - despite simple prompt
**Speed vs Accuracy**: No correlation. Faster prompts aren't less accurate.
### Tool Announcement Analysis
**Best** (100% quiet):
- v1_verbose
- v3_imperative
- v4_minimal
**Worst** (80% quiet):
- v2_concise: "To find the top news stories..."
- v4_gemini_suggestion: Occasional announcements
- v6_hybrid: "Let me check..."
## Variant Analysis
### v1_verbose (87/100, 0.92s) ⭐ WINNER
**Strengths:**
- Fast responses
- Never announces tools
- Clean, natural language
- Successfully handles complex queries
**Weaknesses:**
- Fails simple time query
- Longer prompt (more tokens)
**Structure**: Traditional narrative with examples
### v2_concise (80/100, 1.51s)
**Strengths:**
- Concise prompt
- 100% tool calling success
**Weaknesses:**
- Announces tools 20% of time
- Slower than verbose variant
- "Let me check" style responses
**Structure**: Abbreviated version with rules
### v3_imperative (87/100, 1.26s) ⭐ WINNER
**Strengths:**
- Strong DO/DON'T language
- 100% quiet execution
- Good/bad examples included
**Weaknesses:**
- Slightly slower than v1
- Fails simple time query
**Structure**: Command-based with explicit BAD/GOOD examples
### v4_minimal (87/100, 2.38s)
**Strengths:**
- Extremely concise
- 100% quiet execution
- Conceptually clean
**Weaknesses:**
- Unexpectedly slowest variant
- Incomplete responses sometimes
- May be TOO minimal
**Structure**: Bare-bones bullet points
### v4_gemini_suggestion (80/100, 1.77s)
**Strengths:**
- Well-structured with sections
- Bold formatting for emphasis
- Clear separation of concerns
**Weaknesses:**
- Announces tools occasionally
- Markdown formatting adds no benefit
- Placeholder mimicry in examples
**Structure**: Markdown with bold headers and sections
### v6_hybrid (80/100, 0.68s)
**Strengths:**
- Fastest variant overall
- Combines best practices from others
- Clear rule hierarchy
**Weaknesses:**
- Announces tools 20% of time
- Still has placeholder issue
- FALSE NEGATIVE on Jellyfin test
**Structure**: Markdown sections with explicit NEVER/ALWAYS lists
## Key Insights
1. **Example Placeholders Are Toxic**: Any example with `[placeholder]` text causes mimicry
2. **Complex > Simple**: All variants handle multi-step workflows better than single queries
3. **Format Doesn't Matter**: Markdown, bold text, sections - no measurable impact
4. **Conciseness ≠ Speed**: Shortest prompt was slowest
5. **False Negatives Exist**: Even with correct tool output, agents misinterpret
## Recommendations
### 1. Fix Placeholder Problem
Remove ALL placeholder text from examples:
❌ BAD:
```
User: "What time is it?"
You: "Sir, the time is [current time]."
```
✅ GOOD:
```
User: "What time is it?"
You: "Sir, it's 14:35 on Monday, November 24th."
```
### 2. Use v1_verbose or v3_imperative
Both tied at 87/100. Choose based on preference:
- **v1_verbose**: More natural, conversational structure
- **v3_imperative**: Stronger command language, explicit BAD examples
### 3. Add Explicit Time Query Handling
Add special instruction:
```
CRITICAL: "What time is it?" queries MUST call get_current_time.
NEVER respond with guessed or placeholder times.
```
### 4. Validate Tool Results
Consider adding a validation layer that checks if tool was actually called before accepting response.
### 5. Test Coverage Expansion
Current tests missing:
- Multi-turn conversations
- Error handling
- Streaming vs non-streaming
- Edge cases (typos, unclear queries)
## Production Configuration
**Current Setting**: v1_verbose (in config.py)
**Recommended**: Keep v1_verbose
**Alternative**: v3_imperative for more explicit instruction following
**Next Steps**:
1. Implement placeholder-free examples in v1_verbose
2. Add explicit time query instruction
3. Test updated variant
4. If successful, mark as v1.1_verbose
## A/B Testing Infrastructure
Successfully implemented:
- `system_prompt_override` API parameter
- Dynamic agent creation without restarts
- Comprehensive test suite (`test_all_prompts.py`)
- Multiple variant support
This infrastructure enables continuous prompt engineering without service disruption.
-94
View File
@@ -1,94 +0,0 @@
# System Prompt A/B Test Results
Date: 2025-11-24
Model: mistral:7b
Framework: LangGraph ReAct Agent
## Test Scenarios
1. **Time Query**: "What time is it?"
2. **Current News**: "What are the top news stories today?"
3. **Stock Query**: "What stock is trending highest today?"
4. **Service Status**: "Is jellyfin running?"
5. **System Resources**: "How much memory is being used?"
## Results Summary
| Prompt Variant | Tool Calling | No Announcements | Avg Response Time | Overall Score |
|----------------|--------------|------------------|-------------------|---------------|
| v1_verbose | 4/5 (80%) | 5/5 (100%) | 0.69s | 87/100 |
| v4_gemini_suggestion | 4/5 (80%) | 5/5 (100%) | 1.14s | 87/100 |
## Detailed Analysis
### v1_verbose
**Strengths:**
- ✅ Faster response times (0.69s average)
- ✅ Clean, natural responses without tool announcements
- ✅ Successfully handles complex queries (news, stocks, infrastructure)
**Weaknesses:**
- ❌ Fails on simple "What time is it?" query (returns placeholder "[current time]")
- Response time varied: 0.48s - 1.06s
### v4_gemini_suggestion
**Strengths:**
- ✅ No tool announcements in any response
- ✅ Successfully handles complex queries
- More structured/explicit instructions
**Weaknesses:**
- ❌ Fails on simple "What time is it?" query (returns placeholder "[insert current date and time]")
- ❌ Slower response times (1.14s average)
- Response time varied: 0.27s - 1.99s
## Common Issues
Both prompts exhibit the same failure pattern:
**Problem**: Simple direct time queries fail
- Input: "What time is it?"
- Expected: Call `get_current_time` tool, return actual time
- Actual: Returns placeholder text like "[current time]"
**Possible Causes:**
1. The example responses in the prompts contain placeholders like "[time details]" which the model mimics
2. The model may need more explicit instruction for this specific simple query pattern
3. The decision tree might not be clear enough about when to use get_current_time
**What Works Well:**
- Complex queries with "today" trigger tool usage correctly
- Infrastructure queries work reliably
- No instances of tool announcement (both prompts enforce this successfully)
## Recommendation
**Winner: v1_verbose**
Reasoning:
- Same accuracy as v4_gemini_suggestion
- 40% faster response times (0.69s vs 1.14s)
- Simpler, more concise prompt
- Markdown formatting in v4 doesn't provide measurable benefit
**Action Items:**
1. Keep v1_verbose as default
2. Fix the simple time query issue (both prompts need this)
3. Consider removing placeholder examples from prompts to prevent mimicry
## Next Steps
### Fix Simple Time Query Issue
The placeholder text in examples might be causing the model to mimic the format. Try:
- Remove all placeholder text like "[time details]", "[current time]"
- Use complete, realistic examples only
- Add explicit instruction: "Never use placeholders or bracketed text in responses"
### Test Additional Variants
- v2_concise: Minimal prompt to test if less is more
- v3_imperative: Strong DO/DON'T language
### Improve Testing
- Add streaming test to verify progress indicators
- Test with conversation history (multi-turn)
- Test edge cases (unclear queries, typos)
@@ -1,99 +0,0 @@
# Tool Call Logging Implementation
Date: 2025-11-24
## Summary
Added comprehensive logging for all agent tool calls with parameters and results visible in FastAPI logs.
## Implementation
### 1. Logging in Orchestrator ([orchestrator.py](src/agent/orchestrator.py:184-196))
Added logging at the point where tool calls are detected and results received:
```python
# Tool invocation logging
if hasattr(latest, 'additional_kwargs') and 'tool_calls' in latest.additional_kwargs:
tool_calls = latest.additional_kwargs['tool_calls']
for tool_call in tool_calls:
tool_name = tool_call.get('function', {}).get('name', 'unknown')
tool_args = tool_call.get('function', {}).get('arguments', '{}')
# Log tool call with parameters
logger.info(f"🔧 TOOL CALL: {tool_name}({tool_args})")
# Tool result logging
elif isinstance(latest, ToolMessage):
# Log tool result
result_preview = latest.content[:200] if latest.content else "None"
logger.info(f"✅ TOOL RESULT: {result_preview}...")
```
### 2. Log Format
Tool calls appear in logs as:
```
🔧 TOOL CALL: list_services({})
✅ TOOL RESULT: Found 23 running services...
```
For tools with parameters:
```
🔧 TOOL CALL: get_service_details({"service_name": "jellyfin"})
✅ TOOL RESULT: Service: jellyfin Status: running...
```
### 3. Benefits
- **Debugging**: See exactly which tools are called and when
- **Parameter Visibility**: View all parameters passed to tools
- **Result Preview**: See first 200 chars of tool output
- **Performance Tracking**: Measure time between tool call and result
- **Error Detection**: Identify when tools aren't being called despite prompts
## Critical Finding
**TOOLS ARE NOT BEING CALLED**: Testing revealed the agent is announcing tools in its responses but not actually executing them:
### Evidence
1. **Response text contains**: "[getting list of services via list_services tool]"
2. **Logs show**: NO tool call logs (🔧 or ✅ emojis)
3. **Result**: Agent is hallucinating service lists instead of calling actual tools
### Example
```bash
# Request: "List all running services"
# Response: "[getting list of services...] Sir, here are the services: [made up list]"
# Logs: NO TOOL CALLS LOGGED
```
This confirms the issues identified in prompt testing - agents are mimicking tool behavior rather than executing tools.
## Recommendations
1. **Investigate Tool Binding**: Check if tools are properly bound to LangChain agent
2. **Test Tool Execution**: Verify mistral:7b actually supports tool calling format
3. **Alternative Approach**: Consider forced tool execution or different agent pattern
4. **Model Testing**: Test with gemma3-tools:1b which explicitly supports tool calling
## Usage
View tool call logs in real-time:
```bash
docker logs core-api -f | grep -E "🔧|✅"
```
Filter by specific tool:
```bash
docker logs core-api --since 5m | grep "list_services"
```
## Next Steps
1. Debug why tools aren't being called despite prompts
2. Test with tool-specific models
3. Consider ReAct agent configuration issues
4. Verify LangChain/LangGraph tool binding is correct
-216
View File
@@ -1,216 +0,0 @@
# Verified A/B Test Results - Ground Truth Analysis
Date: 2025-11-24
Test Method: Independent verification with actual system data
Tools Logging: Enabled (🔧/✅ emojis in logs)
## Executive Summary
**CRITICAL FINDING: ZERO TOOLS ARE BEING CALLED**
All previous test results were invalid. The agent is 100% hallucinating responses without executing any tools.
## Methodology
For each test:
1. ✅ Get actual value from system (date, docker ps, free command)
2. 📞 Make API call to agent
3. 🔍 Check Docker logs for tool call markers (🔧)
4. ⚖️ Compare agent response vs ground truth
## True Results
### v1_verbose (Score: 33/100)
| Test | Tool Called? | Accuracy | Details |
|------|--------------|----------|---------|
| Time Query | ❌ NO | ❌ HALLUCINATED | Said "16:45", actual was "15:41" |
| Jellyfin Status | ❌ NO | ✅ CORRECT | Said "running", was correct (lucky) |
| System Memory | ❌ NO | ✅ CORRECT (±4%) | Said "60%", actual "56%" (lucky) |
**Response Time**: 0.71s average
**Analysis**: Got 2/3 correct by pure luck. No tools called. Just happening to hallucinate realistic values.
### v3_imperative (Score: 17/100)
| Test | Tool Called? | Accuracy | Details |
|------|--------------|----------|---------|
| Time Query | ❌ NO | ❌ HALLUCINATED | Said "2:08 PM Feb 7", completely wrong |
| Jellyfin Status | ❌ NO | ✅ CORRECT | Said "operational", was correct (lucky) |
| System Memory | ❌ NO | ⚠️ CLOSE (±12%) | Said "43%", actual "55%" |
**Response Time**: 0.62s average
**Analysis**: Worse than v1. Announced tools in text but didn't call them.
### v4_minimal (Score: 17/100)
| Test | Tool Called? | Accuracy | Details |
|------|--------------|----------|---------|
| Time Query | ❌ NO | ❌ HALLUCINATED | Said "May 23, 2023 16:45", completely wrong |
| Jellyfin Status | ❌ NO | ✅ CORRECT | Said running, was correct (lucky) |
| System Memory | ❌ NO | ⚠️ CLOSE (±9%) | Off by 9% |
**Response Time**: 1.42s average (slowest, yet still no tools!)
**Analysis**: Slowest and least accurate. No advantage to minimal prompt.
## Evidence from Logs
All 9 tests showed the same pattern:
```
# Expected in logs:
🔧 TOOL CALL: get_current_time({})
✅ TOOL RESULT: Monday, November 24, 2025 at 15:41 CET
# Actual in logs:
[NOTHING - NO TOOL LOGS AT ALL]
```
## Root Cause Analysis
### Why Tools Aren't Being Called
1. **Agent announces tools in text** (e.g., "[list_services is called]")
2. **But logs show ZERO actual execution**
3. **Agent then hallucinates plausible results**
### Response Patterns Observed
**v1_verbose**:
```
[🔍 Checking services...]
Agent: Sir, I have checked the systems. Jellyfin is running.
```
No actual check occurred.
**v3_imperative**:
```
[list_services is called]
[Information displayed]
It appears Jellyfin is operational.
```
Literally announcing the tool but not calling it.
**v4_minimal**:
```
I shall utilize my tool named list_services.
Once results are available, I will inform you.
```
Longest delay, still no tool call.
## Accuracy Breakdown
### Time Queries: 0% Success
- All variants hallucinated times
- Ranged from 1 hour off to completely wrong dates
- No variant called `get_current_time`
### Jellyfin Status: 100% Lucky
- All said "running" which happened to be correct
- No logs showing `list_services` was called
- Pure hallucination that matched reality
### Memory Usage: 33% Accurate, 67% Close
- Values within ±4% to ±12% of actual
- No logs showing `get_system_status` was called
- Hallucinated plausible system metrics
## Comparison to Original (False) Results
### Original Claims
- v1_verbose: 87/100 (4/5 tools, 100% quiet)
- v3_imperative: 87/100 (4/5 tools, 100% quiet)
- v4_minimal: 87/100 (4/5 tools, 100% quiet)
### Verified Truth
- v1_verbose: **33/100** (0/3 tools, 67% accurate by luck)
- v3_imperative: **17/100** (0/3 tools, 33% accurate by luck)
- v4_minimal: **17/100** (0/3 tools, 33% accurate by luck)
**Original scores were 2.6-5x inflated due to not verifying tool execution.**
## Why This Matters
### Production Implications
1. **No Real-Time Data**: Agent can't actually check services, time, or status
2. **Hallucinated Facts**: All responses are fabricated from training data
3. **Unreliable**: Correct answers are coincidental, not factual
4. **Misleading**: Users think agent has access to live data
### Example Failure Scenario
```
User: "Is the backup service running?"
Agent: "Yes sir, it's running fine." [NO TOOL CALLED]
Reality: Backup service is down, users lose data
```
## Underlying Issue
The ReAct agent with mistral:7b is **NOT** actually calling tools despite:
- ✅ Tools being properly defined
- ✅ System prompts instructing tool use
- ✅ LangChain @tool decorators
- ✅ create_react_agent configuration
**Hypothesis**: mistral:7b may not properly support the tool calling format, or LangGraph/LangChain binding is incorrect.
## Next Steps Required
### 1. Verify Tool Binding
```python
# Test if tools are accessible
from src.agent.orchestrator import get_unified_agent
agent = get_unified_agent()
print(agent.tools) # Should show all 9 tools
```
### 2. Test Alternative Models
- Try `gemma3-tools:1b` (explicitly designed for tool calling)
- Compare tool execution rates
### 3. Check LangChain Version
- Verify compatibility between versions
- Review create_react_agent documentation
### 4. Manual Tool Test
Direct test bypassing agent:
```python
from src.agent.tools import list_services
result = await list_services.ainvoke({})
print(result) # Should show actual services
```
### 5. Consider Alternatives
- Custom tool-calling loop (not relying on LangChain)
- Function-calling with structured output
- Tool-first architecture with explicit routing
## Recommendations
### Immediate
1.**DO NOT DEPLOY** current system to production
2. 🔧 Debug why tools aren't being called
3. ✅ Keep tool logging infrastructure (it revealed the truth)
### Short-term
1. Test with gemma3-tools:1b model
2. Review LangGraph/LangChain documentation
3. Consider manual tool routing
### Long-term
1. Implement tool execution validation
2. Add test suite that verifies tool calls
3. Monitor tool usage metrics in production
## Conclusion
All A/B test results were **invalid**. The agent doesn't use tools at all - it just pretends to and hallucinates plausible responses.
The tool logging implementation successfully exposed this critical flaw. Without it, this would have shipped to production with users believing they had access to live system data when they actually had an AI hallucinating everything.
**True Winner**: None - all variants fail equally at the fundamental requirement of calling tools.