Skip to content

Conversation

@amovfx
Copy link

@amovfx amovfx commented Jun 28, 2025

Summary

  • Fix variable scope error in add_knowledge_base_to_agent function
  • Add new get_info MCP tool to return project location and configuration details

Changes

  1. Bug Fix: Resolved UnboundLocalError in add_knowledge_base_to_agent where the file variable was referenced outside its scope
  2. New Feature: Added get_info endpoint that returns project location, version, base path, and API key status

Test plan

  • Test add_knowledge_base_to_agent with URL parameter
  • Test add_knowledge_base_to_agent with file parameter
  • Test add_knowledge_base_to_agent with text parameter
  • Test get_info endpoint returns correct project information

🤖 Generated with Claude Code

Andrew Oseen and others added 7 commits June 26, 2025 10:59
- Add imports for PromptAgentInputToolsItem_System, SystemToolConfigInputParams_TransferToAgent, and AgentTransfer
- Modify create_conversation_config to accept tools parameter instead of hardcoding end_call tool
- Update create_agent function to support transfer_rules parameter
- Create transfer_to_agent tool configuration when transfer rules are provided
- Include transfer rules information in agent creation response message
…ation

- New MCP tool that takes an agent_id and returns the full conversation_config
- Returns configuration in formatted JSON for easy inspection
- Useful for debugging and understanding agent settings including tools, prompts, and voice configuration
…ration

- New function that properly handles the built_in_tools object structure
- Supports enabling/disabling transfer_to_agent, language_detection, and end_call tools
- Updates both the built_in_tools object and the tools array to maintain consistency
- Properly sets unused tools to null in built_in_tools as per API requirements
- Convert frozen conversation config to dict before modification
- Use create_conversation_config to build new config object
- Ensures compatibility with Pydantic's frozen model instances
- Add CLAUDE.md with project documentation for development guidance

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

Co-Authored-By: Claude <[email protected]>
The function was referencing the 'file' variable outside its scope when
determining the KnowledgeBaseLocator type. Added 'is_file_based' boolean
to track whether the knowledge base is file-based or URL-based.

Fixes: UnboundLocalError: cannot access local variable 'file' where it is not associated with a value

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

Co-Authored-By: Claude <[email protected]>
New MCP tool that provides information about the ElevenLabs MCP server:
- Project location on disk
- Package root directory
- Version information
- Base path configuration
- API key status

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

Co-Authored-By: Claude <[email protected]>

# Extract current conversation config and convert to dict
current_config = agent.conversation_config
config_dict = current_config.model_dump() if hasattr(current_config, 'model_dump') else current_config.__dict__
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a pydantic base model, please remove the hasattr and call model dump directly

Base Path (ELEVENLABS_MCP_BASE_PATH): {base_path or 'Not set (using Desktop)'}
API Key Configured: {'Yes' if api_key else 'No'}"""

return TextContent(type="text", text=info)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont see how this is useful/desirable, please remove or explain why its needed

max_duration_seconds: int = 300,
record_voice: bool = True,
retention_days: int = 730,
transfer_rules: list[dict] | None = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like this! just wondering if we should do this for each system tool? seems weird to do it for only a single one...

"prompt": system_prompt,
"llm": llm,
"tools": [{"type": "system", "name": "end_call", "description": ""}],
"tools": tools if tools is not None else [{"type": "system", "name": "end_call", "description": ""}],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! thanks for catching this!

@@ -0,0 +1,110 @@
# CLAUDE.md
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we add a note here to avoid using hasattr()
seems this agentic coding added a few calls to it we should avoid

@AngeloGiacco
Copy link
Contributor

thanks for the contribution! left a few comments

@mbochneak
Copy link

Thanks for fixing this! I can confirm this bug affects URL-based knowledge bases in real-world usage.

Test Case Validation

I encountered the exact same UnboundLocalError when trying to add URL knowledge bases to agents:

add_knowledge_base_to_agent(
    agent_id="agent_01k0qsr0q4ez0advwkf2hwfc8q",
    knowledge_base_name="Website Knowledge",
    url="https://youradv.com/"
)

Error: cannot access local variable 'file' where it is not associated with a value

Confirmed Behavior

  • Text-based knowledge bases work perfectly
  • File-based knowledge bases work perfectly
  • URL-based knowledge bases fail with the variable scope error

This fix will enable URL scraping for agent knowledge bases, which is a really valuable feature for dynamic content integration.

Looking forward to this being merged! 🎉

@PaulAsjes
Copy link
Collaborator

@amovfx are you able to make the requested changes here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants