DETERMINATOR / ERROR_FIXES_SUMMARY.md
Joseph Pollack
adds youtube video
25435fb unverified

A newer version of the Gradio SDK is available: 6.0.2

Upgrade

Error Fixes Summary

Issues Identified and Fixed

1. ✅ 'Settings' object has no attribute 'ocr_api_url'

Error Location: src/services/image_ocr.py:33

Root Cause: The code was trying to access settings.ocr_api_url which doesn't exist in older versions of the config. This happens when running a previous version of the app where ocr_api_url wasn't added to the Settings class yet.

Fix Applied:

  • Added defensive coding using getattr() with a fallback default URL
  • Default URL: "https://prithivmlmods-multimodal-ocr3.hf.space"

Code Change:

# Before:
self.api_url = api_url or settings.ocr_api_url

# After:
default_url = getattr(settings, "ocr_api_url", None) or "https://prithivmlmods-multimodal-ocr3.hf.space"
self.api_url = api_url or default_url

File: src/services/image_ocr.py


2. ✅ Expected code to be unreachable, but got: ('research_complete', False)

Error Location: src/orchestrator/graph_orchestrator.py (decision node execution)

Root Cause: When Pydantic AI encounters a validation error or returns an unexpected format, it may return a tuple like ('research_complete', False) instead of the expected KnowledgeGapOutput object. The decision function was trying to access result.research_complete on a tuple, causing the error.

Fix Applied:

  1. Enhanced decision function in graph_builder.py to handle tuple formats
  2. Improved tuple handling in graph_orchestrator.py decision node execution
  3. Better reconstruction of KnowledgeGapOutput from validation error tuples

Code Changes:

File: src/agent_factory/graph_builder.py

  • Replaced lambda with named function _decision_function() that handles tuples
  • Added logic to extract research_complete from various tuple formats
  • Handles: ('research_complete', False), dicts in tuples, boolean values in tuples

File: src/orchestrator/graph_orchestrator.py

  • Enhanced tuple detection and reconstruction in _execute_decision_node()
  • Added specific handling for ('research_complete', False) format
  • Improved fallback logic for unexpected tuple formats
  • Better error messages and logging

File: src/orchestrator/graph_orchestrator.py (agent node execution)

  • Improved handling of tuple outputs in _execute_agent_node()
  • Better reconstruction of KnowledgeGapOutput from validation errors
  • More graceful fallback for non-knowledge_gap nodes

3. ⚠️ Local state is not initialized - app is not locally available (Modal TTS)

Error Location: Modal TTS service

Root Cause: This is expected behavior when Modal credentials are not configured or the app is not running in a Modal environment. It's not a critical error - TTS will simply be unavailable.

Status:

  • This is not an error - it's expected when Modal isn't configured
  • The app gracefully degrades and continues without TTS
  • Users can still use the app, just without audio output

No Fix Needed: This is working as designed with graceful degradation.


4. ⚠️ Invalid file descriptor: -1 (Asyncio cleanup)

Error Location: Python asyncio event loop cleanup

Root Cause: This is a Python asyncio cleanup warning that occurs during shutdown. It's not critical and doesn't affect functionality.

Status:

  • This is a warning, not an error
  • Occurs during application shutdown
  • Doesn't affect runtime functionality
  • Common in Python 3.11+ with certain asyncio patterns

No Fix Needed: This is a known Python asyncio quirk and doesn't impact functionality.


5. ⚠️ MCP Server Warning: gr.State input will not be updated between tool calls

Error Location: Gradio MCP server setup

Root Cause: Some MCP tools use gr.State inputs, which Gradio warns won't update between tool calls. This is a limitation of how MCP tools interact with Gradio state.

Status:

  • This is a warning, not an error
  • MCP tools will still work, but state won't persist between calls
  • This is a known Gradio MCP limitation

No Fix Needed: This is a Gradio limitation, not a bug in our code.


Summary of Fixes

Critical Fixes (Applied):

  1. OCR API URL Attribute Error - Fixed with defensive coding
  2. Graph Orchestrator Tuple Handling - Fixed with enhanced tuple detection and reconstruction

Non-Critical (Expected Behavior):

  1. ⚠️ Modal TTS Error - Expected when Modal not configured (graceful degradation)
  2. ⚠️ Asyncio Cleanup Warning - Python asyncio quirk (non-critical)
  3. ⚠️ MCP State Warning - Gradio limitation (non-critical)

Testing Recommendations

  1. Test OCR functionality:

    • Upload an image with text
    • Verify OCR processing works
    • Check logs for any remaining errors
  2. Test graph execution:

    • Run a research query
    • Verify knowledge gap evaluation works
    • Check that decision nodes route correctly
    • Monitor logs for tuple handling warnings
  3. Test with/without Modal:

    • Verify app works without Modal credentials
    • Test TTS if Modal is configured
    • Verify graceful degradation

Files Modified

  1. src/services/image_ocr.py - Added defensive ocr_api_url access
  2. src/orchestrator/graph_orchestrator.py - Enhanced tuple handling in decision and agent nodes
  3. src/agent_factory/graph_builder.py - Improved decision function to handle tuples

Next Steps

  1. Test the fixes with the reported error scenarios
  2. Monitor logs for any remaining issues
  3. Consider adding unit tests for tuple handling edge cases
  4. Document the tuple format handling for future reference