Skip to content

Ensure liveness in synchronous settings #807

@javiermtorres

Description

@javiermtorres

When using the synchronous versions of create and run, and then trying to perform cleanup of the tool resources, the runtime will stall:

from any_agent import AnyAgent, AgentConfig
from any_agent.config import MCPStdio
import asyncio

tool_args = [
    "-y",
    "@modelcontextprotocol/server-filesystem",
    ".",
]

agent = AnyAgent.create(
    agent_framework="openai",
    agent_config=AgentConfig(
        model_id="o3",
        instructions="Use the tools to answer the query.",
        tools=[
            MCPStdio(
                command="npx",
                args=tool_args,
                tools=[
                    "read_file",
                    "list_directory",
                ],
            ),
        ],
    ),
)
agent.run("Find all files in the current directory that have 'primer' in the title.")
asyncio.run(agent._mcp_clients[0].disconnect())

The cleanup procedures are not yet well defined, so this issue may also include a first version of cleanup contracts inside the library and towards the user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions