From 5434708eb655205a79c8257c868fa04dfadab581 Mon Sep 17 00:00:00 2001 From: codegen-bot Date: Tue, 4 Mar 2025 01:32:18 +0000 Subject: [PATCH 1/2] . --- src/codegen/agents/code_agent.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/codegen/agents/code_agent.py b/src/codegen/agents/code_agent.py index cb7be3ffa..bd9d501b9 100644 --- a/src/codegen/agents/code_agent.py +++ b/src/codegen/agents/code_agent.py @@ -32,10 +32,12 @@ def __init__(self, codebase: "Codebase", model_provider: str = "anthropic", mode - max_tokens: Maximum number of tokens to generate """ self.codebase = codebase + if tools is None: + tools = [] + tools = [tool for tool in tools if tool.name not in ['reveal_symbol', 'move_symbol']] self.agent = create_codebase_agent(self.codebase, model_provider=model_provider, model_name=model_name, memory=memory, additional_tools=tools, **kwargs) self.langsmith_client = Client() - # Get project name from environment variable or use a default self.project_name = os.environ.get("LANGCHAIN_PROJECT", "RELACE") print(f"Using LangSmith project: {self.project_name}") @@ -52,14 +54,10 @@ def run(self, prompt: str, thread_id: Optional[str] = None) -> str: if thread_id is None: thread_id = str(uuid4()) - # this message has a reducer which appends the current message to the existing history - # see more https://langchain-ai.github.io/langgraph/concepts/low_level/#reducers input = {"messages": [("user", prompt)]} - # we stream the steps instead of invoke because it allows us to access intermediate nodes stream = self.agent.stream(input, config={"configurable": {"thread_id": thread_id, "metadata": {"project": self.project_name}}, "recursion_limit": 100}, stream_mode="values") - # Keep track of run IDs from the stream run_ids = [] for s in stream: @@ -72,16 +70,12 @@ def run(self, prompt: str, thread_id: Optional[str] = None) -> str: else: message.pretty_print() - # Try to extract run ID if available in metadata if hasattr(message, "additional_kwargs") and "run_id" in message.additional_kwargs: run_ids.append(message.additional_kwargs["run_id"]) - # Get the last message content result = s["messages"][-1].content - # Try to find run IDs in the LangSmith client's recent runs try: - # Find and print the LangSmith run URL find_and_print_langsmith_run_url(self.langsmith_client, self.project_name) except Exception as e: separator = "=" * 60 @@ -100,7 +94,6 @@ def get_agent_trace_url(self) -> str | None: The URL for the run in LangSmith if found, None otherwise """ try: - # TODO - this is definitely not correct, we should be able to get the URL directly... return find_and_print_langsmith_run_url(client=self.langsmith_client, project_name=self.project_name) except Exception as e: separator = "=" * 60 @@ -109,4 +102,4 @@ def get_agent_trace_url(self) -> str | None: print(traceback.format_exc()) print(separator) - return None + return None \ No newline at end of file From 4561352e51b6817ec2cc88493b89e03547d11d16 Mon Sep 17 00:00:00 2001 From: codegen-team <135641899+codegen-team@users.noreply.github.com> Date: Tue, 4 Mar 2025 01:33:12 +0000 Subject: [PATCH 2/2] Automated pre-commit update --- src/codegen/agents/code_agent.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/codegen/agents/code_agent.py b/src/codegen/agents/code_agent.py index bd9d501b9..3e1069d75 100644 --- a/src/codegen/agents/code_agent.py +++ b/src/codegen/agents/code_agent.py @@ -34,7 +34,7 @@ def __init__(self, codebase: "Codebase", model_provider: str = "anthropic", mode self.codebase = codebase if tools is None: tools = [] - tools = [tool for tool in tools if tool.name not in ['reveal_symbol', 'move_symbol']] + tools = [tool for tool in tools if tool.name not in ["reveal_symbol", "move_symbol"]] self.agent = create_codebase_agent(self.codebase, model_provider=model_provider, model_name=model_name, memory=memory, additional_tools=tools, **kwargs) self.langsmith_client = Client() @@ -102,4 +102,4 @@ def get_agent_trace_url(self) -> str | None: print(traceback.format_exc()) print(separator) - return None \ No newline at end of file + return None