From f8872846db46b7a8d076a97baee4720f415f02c6 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Mon, 14 Apr 2025 21:39:20 +0800 Subject: [PATCH 1/4] Update [ghstack-poisoned] --- codemcp/agno.py | 31 ++++++++++++++++++++++++------- codemcp/main.py | 4 +++- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/codemcp/agno.py b/codemcp/agno.py index 5768bf2..61f56d1 100644 --- a/codemcp/agno.py +++ b/codemcp/agno.py @@ -7,9 +7,7 @@ from agno.api.playground import PlaygroundEndpointCreate, create_playground_endpoint from agno.cli.console import console from agno.cli.settings import agno_cli_settings -from agno.models.anthropic import Claude from agno.models.google import Gemini -from agno.playground import Playground from agno.tools.mcp import MCPTools from agno.utils.log import logger from fastapi import FastAPI @@ -67,23 +65,42 @@ async def main(): async with MCPTools(f"{sys.executable} -m codemcp.hot_reload_entry") as codemcp: # TODO: cli-ify the model agent = Agent( - #model=Claude(id="claude-3-7-sonnet-20250219"), + # model=Claude(id="claude-3-7-sonnet-20250219"), model=Gemini(id="gemini-2.5-pro-exp-03-25"), tools=[codemcp], instructions="", markdown=True, show_tool_calls=True, ) - #agent.print_response("What tools do you have?", stream=True, show_full_reasoning=True, stream_intermediate_steps=True) - #return - playground = Playground(agents=[agent]).get_app() - await serve_playground_app_async(playground) + # agent.print_response("What tools do you have?", stream=True, show_full_reasoning=True, stream_intermediate_steps=True) + # return + + # Comment out the playground code + # playground = Playground(agents=[agent]).get_app() + # await serve_playground_app_async(playground) + + # Replace with a simple stdin loop + print("Enter your query (Ctrl+C to exit):") + while True: + try: + user_input = input("> ") + agent.print_response( + user_input, + stream=True, + show_full_reasoning=True, + stream_intermediate_steps=True, + ) + except KeyboardInterrupt: + print("\nExiting...") + break if __name__ == "__main__": from agno.debug import enable_debug_mode + enable_debug_mode() import logging + logging.basicConfig(level=logging.DEBUG) logging.getLogger("httpx").setLevel(logging.DEBUG) # For HTTP logging logging.getLogger("anthropic").setLevel(logging.DEBUG) diff --git a/codemcp/main.py b/codemcp/main.py index 1f1e735..4cdf329 100644 --- a/codemcp/main.py +++ b/codemcp/main.py @@ -67,7 +67,9 @@ async def codemcp( subtool: str, *, path: str | None = None, - content: str | dict | None = None, # Allow any type, will be serialized to string if needed + content: str + | dict + | None = None, # Allow any type, will be serialized to string if needed old_string: str | None = None, new_string: str | None = None, offset: int | None = None, From 01e89dbd81db80264ee94803d85b179f3878f7a8 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Mon, 14 Apr 2025 21:43:59 +0800 Subject: [PATCH 2/4] Update [ghstack-poisoned] --- codemcp/agno.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/codemcp/agno.py b/codemcp/agno.py index 61f56d1..6ad20fb 100644 --- a/codemcp/agno.py +++ b/codemcp/agno.py @@ -79,12 +79,16 @@ async def main(): # playground = Playground(agents=[agent]).get_app() # await serve_playground_app_async(playground) - # Replace with a simple stdin loop + # Replace with a simple async loop for stdin input print("Enter your query (Ctrl+C to exit):") while True: try: - user_input = input("> ") - agent.print_response( + # Use asyncio to read from stdin in an async-friendly way + loop = asyncio.get_event_loop() + user_input = await loop.run_in_executor(None, lambda: input("> ")) + + # Properly await the async print_response method + await agent.print_response( user_input, stream=True, show_full_reasoning=True, From 7be9470681c50c55505b7b918ff42b1745243a0c Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Mon, 14 Apr 2025 21:50:08 +0800 Subject: [PATCH 3/4] Update [ghstack-poisoned] --- codemcp/agno.py | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/codemcp/agno.py b/codemcp/agno.py index 6ad20fb..c71c90c 100644 --- a/codemcp/agno.py +++ b/codemcp/agno.py @@ -61,6 +61,17 @@ async def serve_playground_app_async( await server.serve() +# This function handles a single query +async def process_query(agent, query): + """Process a single query with the agent.""" + await agent.print_response( + query, + stream=True, + show_full_reasoning=True, + stream_intermediate_steps=True, + ) + + async def main(): async with MCPTools(f"{sys.executable} -m codemcp.hot_reload_entry") as codemcp: # TODO: cli-ify the model @@ -79,24 +90,17 @@ async def main(): # playground = Playground(agents=[agent]).get_app() # await serve_playground_app_async(playground) - # Replace with a simple async loop for stdin input + # Replace with a simple CLI input loop print("Enter your query (Ctrl+C to exit):") - while True: - try: - # Use asyncio to read from stdin in an async-friendly way - loop = asyncio.get_event_loop() - user_input = await loop.run_in_executor(None, lambda: input("> ")) - - # Properly await the async print_response method - await agent.print_response( - user_input, - stream=True, - show_full_reasoning=True, - stream_intermediate_steps=True, - ) - except KeyboardInterrupt: - print("\nExiting...") - break + try: + while True: + # Get input from user (non-async operation) + user_input = input("> ") + + # Process the query in an async way + await process_query(agent, user_input) + except KeyboardInterrupt: + print("\nExiting...") if __name__ == "__main__": From 887bd133ca722f6dabb09cd8584e697862a33dcc Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Mon, 14 Apr 2025 21:58:48 +0800 Subject: [PATCH 4/4] Update [ghstack-poisoned] --- codemcp/agno.py | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/codemcp/agno.py b/codemcp/agno.py index c71c90c..6ad20fb 100644 --- a/codemcp/agno.py +++ b/codemcp/agno.py @@ -61,17 +61,6 @@ async def serve_playground_app_async( await server.serve() -# This function handles a single query -async def process_query(agent, query): - """Process a single query with the agent.""" - await agent.print_response( - query, - stream=True, - show_full_reasoning=True, - stream_intermediate_steps=True, - ) - - async def main(): async with MCPTools(f"{sys.executable} -m codemcp.hot_reload_entry") as codemcp: # TODO: cli-ify the model @@ -90,17 +79,24 @@ async def main(): # playground = Playground(agents=[agent]).get_app() # await serve_playground_app_async(playground) - # Replace with a simple CLI input loop + # Replace with a simple async loop for stdin input print("Enter your query (Ctrl+C to exit):") - try: - while True: - # Get input from user (non-async operation) - user_input = input("> ") - - # Process the query in an async way - await process_query(agent, user_input) - except KeyboardInterrupt: - print("\nExiting...") + while True: + try: + # Use asyncio to read from stdin in an async-friendly way + loop = asyncio.get_event_loop() + user_input = await loop.run_in_executor(None, lambda: input("> ")) + + # Properly await the async print_response method + await agent.print_response( + user_input, + stream=True, + show_full_reasoning=True, + stream_intermediate_steps=True, + ) + except KeyboardInterrupt: + print("\nExiting...") + break if __name__ == "__main__":