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

fix: additional tools won't duplicate #928

Merged
merged 2 commits into from
Mar 20, 2025
Merged
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
14 changes: 5 additions & 9 deletions src/codegen/extensions/langchain/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"""
llm = LLM(model_provider=model_provider, model_name=model_name, **kwargs)

# Get all codebase tools
# Initialize default tools
tools = [
ViewFileTool(codebase),
ListDirectoryTool(codebase),
Expand All @@ -80,22 +80,18 @@
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:
# Get names of additional tools
additional_names = {t.get_name() for t in additional_tools}
# Keep only tools that don't have matching names in additional_tools
tools = [t for t in tools if t.get_name() not in additional_names]
tools.extend(additional_tools)

memory = MemorySaver() if memory else None

Check failure on line 92 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 94 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 94 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 Down Expand Up @@ -143,9 +139,9 @@
if additional_tools:
tools.extend(additional_tools)

memory = MemorySaver() if memory else None

Check failure on line 142 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 144 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 +178,8 @@
RevealSymbolTool(codebase),
]

memory = MemorySaver() if memory else None

Check failure on line 181 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 182 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 +212,6 @@
"""
llm = LLM(model_provider=model_provider, model_name=model_name, **kwargs)

memory = MemorySaver() if memory else None

Check failure on line 215 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 217 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]
Loading