Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change additional Tools to Tools #926

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/codegen/agents/chat_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self, codebase: "Codebase", model_provider: str = "anthropic", mode
- max_tokens: Maximum number of tokens to generate
"""
self.codebase = codebase
self.agent = create_chat_agent(self.codebase, model_provider=model_provider, model_name=model_name, memory=memory, additional_tools=tools, **kwargs)
self.agent = create_chat_agent(self.codebase, model_provider=model_provider, model_name=model_name, memory=memory, tools=tools, **kwargs)

def run(self, prompt: str, thread_id: Optional[str] = None) -> str:
"""Run the agent with a prompt.
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/agents/code_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
model_provider=model_provider,
model_name=model_name,
memory=memory,
additional_tools=tools,
tools=tools,
config=agent_config,
**kwargs,
)
Expand All @@ -87,7 +87,7 @@
print(f"Using LangSmith project: {self.project_name}")

# Store SWEBench metadata if provided
self.run_id = metadata.get("run_id")

Check failure on line 90 in src/codegen/agents/code_agent.py

View workflow job for this annotation

GitHub Actions / mypy

error: Item "None" of "dict[Any, Any] | None" has no attribute "get" [union-attr]
self.instance_id = metadata.get("instance_id")
# Extract difficulty value from "difficulty_X" format
difficulty_str = metadata.get("difficulty", "")
Expand Down
81 changes: 36 additions & 45 deletions src/codegen/extensions/langchain/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
system_message: SystemMessage = SystemMessage(REASONER_SYSTEM_MESSAGE),
memory: bool = True,
debug: bool = False,
additional_tools: list[BaseTool] | None = None,
tools: list[BaseTool] | None = None,
config: AgentConfig | None = None,
**kwargs,
) -> CompiledGraph:
Expand All @@ -63,39 +63,32 @@
"""
llm = LLM(model_provider=model_provider, model_name=model_name, **kwargs)

# Get all codebase tools
tools = [
ViewFileTool(codebase),
ListDirectoryTool(codebase),
RipGrepTool(codebase),
# EditFileTool(codebase),
CreateFileTool(codebase),
DeleteFileTool(codebase),
RenameFileTool(codebase),
# MoveSymbolTool(codebase),
# RevealSymbolTool(codebase),
# SemanticEditTool(codebase),
ReplacementEditTool(codebase),
RelaceEditTool(codebase),
ReflectionTool(codebase),
SearchFilesByNameTool(codebase),
GlobalReplacementEditTool(codebase),
# SemanticSearchTool(codebase),
# =====[ Github Integration ]=====
# Enable Github integration
# GithubCreatePRTool(codebase),
# GithubViewPRTool(codebase),
# GithubCreatePRCommentTool(codebase),
# GithubCreatePRReviewCommentTool(codebase),
]

# Add additional tools if provided
if additional_tools:
tools.extend(additional_tools)
if not tools:
tools = [
ViewFileTool(codebase),
ListDirectoryTool(codebase),
RipGrepTool(codebase),
# EditFileTool(codebase),
CreateFileTool(codebase),
DeleteFileTool(codebase),
RenameFileTool(codebase),
ReplacementEditTool(codebase),
RelaceEditTool(codebase),
ReflectionTool(codebase),
SearchFilesByNameTool(codebase),
GlobalReplacementEditTool(codebase),
# SemanticSearchTool(codebase),
# =====[ Github Integration ]=====
# Enable Github integration
# GithubCreatePRTool(codebase),
# GithubViewPRTool(codebase),
# GithubCreatePRCommentTool(codebase),
# GithubCreatePRReviewCommentTool(codebase),
]

memory = MemorySaver() if memory else None

Check failure on line 89 in src/codegen/extensions/langchain/agent.py

View workflow job for this annotation

GitHub Actions / mypy

error: Incompatible types in assignment (expression has type "InMemorySaver | None", variable has type "bool") [assignment]

return create_react_agent(model=llm, tools=tools, system_message=system_message, checkpointer=memory, debug=debug, config=config)

Check failure on line 91 in src/codegen/extensions/langchain/agent.py

View workflow job for this annotation

GitHub Actions / mypy

error: Argument "checkpointer" to "create_react_agent" has incompatible type "bool"; expected "InMemorySaver | None" [arg-type]

Check failure on line 91 in src/codegen/extensions/langchain/agent.py

View workflow job for this annotation

GitHub Actions / mypy

error: Argument "config" to "create_react_agent" has incompatible type "AgentConfig | None"; expected "dict[str, Any] | None" [arg-type]


def create_chat_agent(
Expand All @@ -105,7 +98,7 @@
system_message: SystemMessage = SystemMessage(REASONER_SYSTEM_MESSAGE),
memory: bool = True,
debug: bool = False,
additional_tools: list[BaseTool] | None = None,
tools: list[BaseTool] | None = None,
config: dict[str, Any] | None = None, # over here you can pass in the max length of the number of messages
**kwargs,
) -> CompiledGraph:
Expand All @@ -128,24 +121,22 @@
"""
llm = LLM(model_provider=model_provider, model_name=model_name, **kwargs)

tools = [
ViewFileTool(codebase),
ListDirectoryTool(codebase),
RipGrepTool(codebase),
CreateFileTool(codebase),
DeleteFileTool(codebase),
RenameFileTool(codebase),
MoveSymbolTool(codebase),
RevealSymbolTool(codebase),
RelaceEditTool(codebase),
]

if additional_tools:
tools.extend(additional_tools)
if not tools:
tools = [
ViewFileTool(codebase),
ListDirectoryTool(codebase),
RipGrepTool(codebase),
CreateFileTool(codebase),
DeleteFileTool(codebase),
RenameFileTool(codebase),
MoveSymbolTool(codebase),
RevealSymbolTool(codebase),
RelaceEditTool(codebase),
]

memory = MemorySaver() if memory else None

Check failure on line 137 in src/codegen/extensions/langchain/agent.py

View workflow job for this annotation

GitHub Actions / mypy

error: Incompatible types in assignment (expression has type "InMemorySaver | None", variable has type "bool") [assignment]

return create_react_agent(model=llm, tools=tools, system_message=system_message, checkpointer=memory, debug=debug, config=config)

Check failure on line 139 in src/codegen/extensions/langchain/agent.py

View workflow job for this annotation

GitHub Actions / mypy

error: Argument "checkpointer" to "create_react_agent" has incompatible type "bool"; expected "InMemorySaver | None" [arg-type]


def create_codebase_inspector_agent(
Expand Down Expand Up @@ -182,8 +173,8 @@
RevealSymbolTool(codebase),
]

memory = MemorySaver() if memory else None

Check failure on line 176 in src/codegen/extensions/langchain/agent.py

View workflow job for this annotation

GitHub Actions / mypy

error: Incompatible types in assignment (expression has type "InMemorySaver | None", variable has type "bool") [assignment]
return create_react_agent(model=llm, tools=tools, system_message=system_message, checkpointer=memory, debug=debug, config=config)

Check failure on line 177 in src/codegen/extensions/langchain/agent.py

View workflow job for this annotation

GitHub Actions / mypy

error: Argument "checkpointer" to "create_react_agent" has incompatible type "bool"; expected "InMemorySaver | None" [arg-type]


def create_agent_with_tools(
Expand Down Expand Up @@ -216,6 +207,6 @@
"""
llm = LLM(model_provider=model_provider, model_name=model_name, **kwargs)

memory = MemorySaver() if memory else None

Check failure on line 210 in src/codegen/extensions/langchain/agent.py

View workflow job for this annotation

GitHub Actions / mypy

error: Incompatible types in assignment (expression has type "InMemorySaver | None", variable has type "bool") [assignment]

return create_react_agent(model=llm, tools=tools, system_message=system_message, checkpointer=memory, debug=debug, config=config)

Check failure on line 212 in src/codegen/extensions/langchain/agent.py

View workflow job for this annotation

GitHub Actions / mypy

error: Argument "checkpointer" to "create_react_agent" has incompatible type "bool"; expected "InMemorySaver | None" [arg-type]