Skip to content

Can't create a Langgraph supervisor agent with cohere models AttributeError: 'CohereTool' object has no attribute 'get' #116 #754

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

Open
neeleshkshukla opened this issue Apr 8, 2025 · 5 comments

Comments

@neeleshkshukla
Copy link

Follwoing the readme of https://github.com/langchain-ai/langgraph-supervisor-py, I am trying to create Supervisor agent with Cohere Command R Refresh model. Fails with AttributeError: 'CohereTool' object has no attribute 'get'

https://docs.oracle.com/en-us/iaas/tools/python/2.149.2/api/generative_ai_inference/models/oci.generative_ai_inference.models.CohereTool.html

Code:

from langgraph_supervisor import create_supervisor
from langgraph.prebuilt import create_react_agent


# Create supervisor workflow
workflow = create_supervisor(
    [research_agent, math_agent],
    model=model,
    prompt=(
        "You are a team supervisor managing a research expert and a math expert. "
        "For current events, use research_agent. "
        "For math problems, use math_agent."
    )
)

Error Stacktrace:

AttributeError                            Traceback (most recent call last)
Cell In[19], line 2
      1 # Create supervisor workflow
----> 2 workflow = create_supervisor(
      3     [research_agent, math_agent],
      4     model=model,
      5     prompt=(
      6         "You are a team supervisor managing a research expert and a math expert. "
      7         "For current events, use research_agent. "
      8         "For math problems, use math_agent."
      9     )
     10 )

File ~/lib/python3.13/site-packages/langgraph_supervisor/supervisor.py:211, in create_supervisor(agents, model, tools, prompt, response_format, parallel_tool_calls, state_schema, config_schema, output_mode, add_handoff_back_messages, supervisor_name, include_agent_name)
    208 if include_agent_name:
    209     model = with_agent_name(model, include_agent_name)
--> 211 supervisor_agent = create_react_agent(
    212     name=supervisor_name,
    213     model=model,
    214     tools=all_tools,
    215     prompt=prompt,
    216     state_schema=state_schema,
    217     response_format=response_format,
    218 )
    220 builder = StateGraph(state_schema, config_schema=config_schema)
    221 builder.add_node(supervisor_agent, destinations=tuple(agent_names) + (END,))

File ~/lib/python3.13/site-packages/langgraph/prebuilt/chat_agent_executor.py:154, in _convert_modifier_to_prompt.<locals>.wrapper(*args, **kwargs)
    151     prompt = state_modifier
    153 kwargs["prompt"] = prompt
--> 154 return func(*args, **kwargs)

File ~/lib/python3.13/site-packages/langgraph/prebuilt/chat_agent_executor.py:653, in create_react_agent(model, tools, prompt, response_format, state_schema, config_schema, checkpointer, store, interrupt_before, interrupt_after, debug, version, name)
    649     model = cast(BaseChatModel, init_chat_model(model))
    651 tool_calling_enabled = len(tool_classes) > 0
--> 653 if _should_bind_tools(model, tool_classes) and tool_calling_enabled:
    654     model = cast(BaseChatModel, model).bind_tools(tool_classes)
    656 model_runnable = _get_prompt_runnable(prompt) | model

File ~/lib/python3.13/site-packages/langgraph/prebuilt/chat_agent_executor.py:186, in _should_bind_tools(model, tools)
    183 bound_tool_names = set()
    184 for bound_tool in bound_tools:
    185     # OpenAI-style tool
--> 186     if bound_tool.get("type") == "function":
    187         bound_tool_name = bound_tool["function"]["name"]
    188     # Anthropic-style tool

AttributeError: 'CohereTool' object has no attribute 'get'
@adizohar
Copy link
Member

adizohar commented Apr 8, 2025

You created issue at OCI python sdk but your code is not using the OCI SDK please close the ticket and open in the right repository

@neeleshkshukla
Copy link
Author

neeleshkshukla commented Apr 8, 2025

I am using Using from langchain_community.chat_models import ChatOCIGenAI to create the model.

https://docs.oracle.com/en-us/iaas/tools/python/2.149.2/api/generative_ai_inference/models/oci.generative_ai_inference.models.CohereTool.html

I do see its using oci python sdk AttributeError: 'CohereTool' object has no attribute 'get'

@neeleshkshukla neeleshkshukla reopened this Apr 8, 2025
@adizohar
Copy link
Member

adizohar commented Apr 8, 2025

I don’t see any error that coming from the OCI SDK
Please open ticket at langgraph repository they are not using the OCI sdk properly

@adizohar
Copy link
Member

adizohar commented Apr 8, 2025

I checked the langraph repo and could not find any reference to OCI can you please help me where did you see reference to OCI SDK ?
Please share your full code, you probably didn't use the bound_tool properly, you cannot assign OCI Object to the bound tool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants