Spaces:
Sleeping
Sleeping
| """Phase 0 connectivity proof. | |
| Run with: uv run python -m app._smoke | |
| Goal: prove the OpenAI Agents SDK can connect to the Meridian MCP and | |
| complete one workflow end-to-end. If this succeeds, the rest of the | |
| build is incremental. | |
| """ | |
| import asyncio | |
| from agents import Agent, Runner | |
| from .config import Config | |
| from .mcp_client import build_mcp_server | |
| async def main() -> None: | |
| config = Config() | |
| print(f"MCP URL: {config.mcp_server_url}") | |
| print(f"Model: {config.openai_model}") | |
| print() | |
| async with build_mcp_server(config.mcp_server_url) as mcp_server: | |
| # Sanity check: enumerate tools the SDK sees. | |
| tools = await mcp_server.list_tools() | |
| print(f"Discovered {len(tools)} MCP tools:") | |
| for t in tools: | |
| print(f" - {t.name}") | |
| print() | |
| agent = Agent( | |
| name="meridian-smoke", | |
| instructions=( | |
| "Use the MCP tools to answer the user. Be concise. " | |
| "Never invent product details — always look them up." | |
| ), | |
| model=config.openai_model, | |
| mcp_servers=[mcp_server], | |
| ) | |
| prompt = "What monitors do you sell? List up to 3 with their SKUs." | |
| print(f">>> {prompt}\n") | |
| result = await Runner.run(agent, prompt, max_turns=4) | |
| print(result.final_output) | |
| print() | |
| usage = result.context_wrapper.usage | |
| print( | |
| f"usage: {usage.requests} requests, " | |
| f"{usage.input_tokens} in / {usage.output_tokens} out tokens" | |
| ) | |
| if __name__ == "__main__": | |
| asyncio.run(main()) | |