langflow icon indicating copy to clipboard operation
langflow copied to clipboard

Error running graph: Error building Agent : All of session_id, sender, and sender_name must be provided

Open Owe1n opened this issue 1 year ago • 11 comments

Bug Description

When i try to execute : result = run_flow_from_json( flow="agent.json", input_value="message", session_id="", fallback_to_env_vars=True, tweaks=TWEAKS, )

I have the following error : {"type": "error", "error": "Error running graph: Error building Component Tool Calling Agent: \n\nAll of session_id, sender, and sender_name must be provided."}

I believe it comes from the Tool Calling Agent node.

Reproduction

result = run_flow_from_json( flow="agent.json", input_value="message", session_id="", fallback_to_env_vars=True, tweaks=TWEAKS, )

Expected behavior

Run the flow.

Who can help?

No response

Operating System

Mac OS

Langflow Version

1.1.0

Python Version

3.10

Screenshot

No response

Flow File

No response

Owe1n avatar Nov 19 '24 22:11 Owe1n

Hey @Owe1n! I'm here to help you with any bugs, questions, or contributions. Let's tackle this together!

To resolve the error "Error running graph: Error building Component Tool Calling Agent: All of session_id, sender, and sender_name must be provided," you need to ensure that all three parameters (session_id, sender, and sender_name) are provided and not empty when calling the run_flow_from_json function.

The error occurs because the store_message method in the ChatComponent class requires these parameters to be non-empty:

if not session_id or not sender or not sender_name:
    raise ValueError("All of session_id, sender, and sender_name must be provided.")

To fix this, make sure you provide non-empty values for session_id, sender, and sender_name. For example:

result = run_flow_from_json(
    flow="agent.json",
    input_value="message",
    session_id="your_session_id",  # Provide a valid session_id
    fallback_to_env_vars=True,
    tweaks=TWEAKS,
    sender="User",  # Provide a valid sender
    sender_name="Your Name"  # Provide a valid sender_name
)

Ensure that session_id, sender, and sender_name are not None or empty strings [1].

To continue talking to Dosu, mention @dosu.

dosubot[bot] avatar Nov 19 '24 22:11 dosubot[bot]

I switched it out for the new "Agent" component in v1.1. I'd use that.

SavvySupport avatar Nov 20 '24 00:11 SavvySupport

@SavvySupport I've seen but for some reason the results were better in my flow with the ToolCalling agent.

Owe1n avatar Nov 20 '24 08:11 Owe1n

Edit :

Actually even the Simple Agent example is no longer working when exporting with python code.

from langflow.load import run_flow_from_json
TWEAKS = {
    "Agent-jeqiW": {
        "add_current_date_tool": True,
        "agent_description": "A helpful assistant with access to the following tools:",
        "agent_llm": "OpenAI",
        "api_key": "open-ai",
        "handle_parsing_errors": True,
        "input_value": "",
        "json_mode": False,
        "max_iterations": 15,
        "max_tokens": None,
        "model_kwargs": {},
        "model_name": "gpt-4o-mini",
        "n_messages": 100,
        "openai_api_base": "",
        "order": "Ascending",
        "output_schema": {},
        "seed": 1,
        "sender": "Machine and User",
        "sender_name": "",
        "session_id": "",
        "system_prompt": "You are a helpful assistant that can use tools to answer questions and perform tasks.\nUse markdown to format your answer, properly embedding images and urls.",
        "temperature": 0.1,
        "template": "{sender_name}: {text}",
        "verbose": True,
    },
    "YahooFinanceTool-ekpEz": {"method": "get_news", "num_news": 5, "symbol": "NVDA"},
    "ChatInput-nWAHv": {
        "background_color": "",
        "chat_icon": "",
        "files": "",
        "input_value": "search news about AAPL",
        "sender": "User",
        "sender_name": "User",
        "session_id": "",
        "should_store_message": True,
        "text_color": "",
    },
    "ChatOutput-Q6TIz": {
        "background_color": "",
        "chat_icon": "",
        "data_template": "{text}",
        "input_value": "",
        "sender": "Machine",
        "sender_name": "AI",
        "session_id": "",
        "should_store_message": True,
        "text_color": "",
    },
}

result = run_flow_from_json(
    flow="Simple Agent.json",
    session_id="",  # provide a session id if you want to use session state
    fallback_to_env_vars=True,  # False by default
    tweaks=TWEAKS,
    input_value="search news about AAPL",
)

Is returning the following error code :

Traceback (most recent call last):
  File "/Users/d/projects/iagentflow_cookbook/ts.py", line 54, in <module>
    result = run_flow_from_json(
  File "/Users/d/miniconda3/envs/iagentflow-cookbook/lib/python3.10/site-packages/langflow/load/load.py", line 171, in run_flow_from_json
    return asyncio.run(coro)
  File "/Users/d/miniconda3/envs/iagentflow-cookbook/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/Users/d/miniconda3/envs/iagentflow-cookbook/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/Users/d/miniconda3/envs/iagentflow-cookbook/lib/python3.10/site-packages/langflow/load/load.py", line 123, in arun_flow_from_json
    result = await run_graph(
  File "/Users/d/miniconda3/envs/iagentflow-cookbook/lib/python3.10/site-packages/langflow/processing/process.py", line 108, in run_graph
    return await graph.arun(
  File "/Users/d/miniconda3/envs/iagentflow-cookbook/lib/python3.10/site-packages/langflow/graph/graph/base.py", line 840, in arun
    run_outputs = await self._run(
  File "/Users/d/miniconda3/envs/iagentflow-cookbook/lib/python3.10/site-packages/langflow/graph/graph/base.py", line 776, in _run
    raise ValueError(msg) from exc
ValueError: Error running graph: Error building Component Agent:

User id is not set for AgentComponent

Owe1n avatar Nov 20 '24 13:11 Owe1n

Hi @Owe1n, thank you for your feedback. We will debug this scenario and update you on our progress.

edwinjosechittilappilly avatar Nov 20 '24 20:11 edwinjosechittilappilly

Hey there, I think the cause of your error is that the error message suggests that the Tool Calling Agent node in your agent.json flow requires one or more of the following parameters: session_id, sender, or sender_name, and at least one of these is missing or empty.

Here is a potential fix based on your error result = run_flow_from_json( flow="agent.json", input_value="message", session_id="user123", # Replace with a valid session ID fallback_to_env_vars=True, tweaks={ "sender": "[email protected]", "sender_name": "User Name", **TWEAKS, # Include other tweaks }, )

elufowojud avatar Nov 21 '24 11:11 elufowojud

Using Langflow 1.1

Still gets this error in JSON parser in a sub-flow.

While the sub-flow independently works without any errors.

Error building Component Fields: 

Error running graph: Error building Component Active Domains JSON: 

All of session_id, sender, and sender_name must be provided.

Traceback (most recent call last):
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/custom/custom_component/component.py", line 837, in build_results
    return await self._build_with_tracing()
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/custom/custom_component/component.py", line 819, in _build_with_tracing
    _results, _artifacts = await self._build_results()
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/custom/custom_component/component.py", line 885, in _build_results
    result = await asyncio.to_thread(method)
  File "/usr/local/Cellar/[email protected]/3.10.15/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/threads.py", line 25, in to_thread
    return await loop.run_in_executor(None, func_call)
  File "/usr/local/Cellar/[email protected]/3.10.15/Frameworks/Python.framework/Versions/3.10/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "<string>", line 74, in clean_json
ValueError: Invalid JSON string: Missing '{' or '}'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/graph/vertex/base.py", line 708, in _build_results
    result = await initialize.loading.get_instance_results(
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/interface/initialize/loading.py", line 68, in get_instance_results
    return await build_component(params=custom_params, custom_component=custom_component)
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/interface/initialize/loading.py", line 145, in build_component
    build_results, artifacts = await custom_component.build_results()
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/custom/custom_component/component.py", line 848, in build_results
    self.send_error(
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/custom/custom_component/component.py", line 1135, in send_error
    self.send_message(error_message)
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/custom/custom_component/component.py", line 1009, in send_message
    stored_message = self._store_message(message)
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/custom/custom_component/component.py", line 1034, in _store_message
    messages = store_message(message, flow_id=flow_id)
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/memory.py", line 167, in store_message
    raise ValueError(msg)
ValueError: All of session_id, sender, and sender_name must be provided.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/graph/graph/base.py", line 771, in _run
    await self.process(start_component_id=start_component_id, fallback_to_env_vars=fallback_to_env_vars)
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/graph/graph/base.py", line 1518, in process
    next_runnable_vertices = await self._execute_tasks(tasks, lock=lock)
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/graph/graph/base.py", line 1570, in _execute_tasks
    raise result
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/graph/graph/base.py", line 1419, in build_vertex
    await vertex.build(
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/graph/vertex/base.py", line 818, in build
    await step(user_id=user_id, event_manager=event_manager, **kwargs)
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/graph/vertex/base.py", line 496, in _build
    await self._build_results(
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/graph/vertex/base.py", line 723, in _build_results
    raise ComponentBuildError(msg, tb) from exc
langflow.exceptions.component.ComponentBuildError: Error building Component Active Domains JSON: 

All of session_id, sender, and sender_name must be provided.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/graph/vertex/base.py", line 708, in _build_results
    result = await initialize.loading.get_instance_results(
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/interface/initialize/loading.py", line 68, in get_instance_results
    return await build_component(params=custom_params, custom_component=custom_component)
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/interface/initialize/loading.py", line 145, in build_component
    build_results, artifacts = await custom_component.build_results()
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/custom/custom_component/component.py", line 837, in build_results
    return await self._build_with_tracing()
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/custom/custom_component/component.py", line 819, in _build_with_tracing
    _results, _artifacts = await self._build_results()
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/custom/custom_component/component.py", line 883, in _build_results
    result = await method()
  File "<string>", line 101, in generate_results
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/custom/custom_component/custom_component.py", line 490, in run_flow
    return await run_flow(
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/helpers/flow.py", line 123, in run_flow
    return await graph.arun(
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/graph/graph/base.py", line 840, in arun
    run_outputs = await self._run(
  File "/.local/pipx/venvs/langflow/lib/python3.10/site-packages/langflow/graph/graph/base.py", line 776, in _run
    raise ValueError(msg) from exc
ValueError: Error running graph: Error building Component Active Domains JSON: 

All of session_id, sender, and sender_name must be provided.

Update : SubFlow works on removing the JSON Parser.

roots-ai avatar Nov 21 '24 12:11 roots-ai

We are addressing this issue and will keep you updated on our progress. Thank you for all your feedback.

edwinjosechittilappilly avatar Nov 25 '24 19:11 edwinjosechittilappilly

I have just removed the check for session_id and now it works fine. Could of course break other things but it unblocked me for now :)

src\backend\base\langflow\memory.py

    if not message.sender or not message.sender_name:
        msg = "All of session_id, sender, and sender_name must be provided."
        raise ValueError(msg)

KevinMichaelSchindler avatar Nov 27 '24 13:11 KevinMichaelSchindler

Error occurred: Error running graph: Error building Component File:

It looks like we're missing some important information: session_id (unique conversation identifier). Please ensure that your message includes all the required fields. facing this error...any solution???

ArchDevData avatar Dec 06 '24 11:12 ArchDevData

Having the same issue. Continue to get the error It looks like we're missing some important information: session_id (unique conversation identifier). Please ensure that your message includes all the required fields. Not sure how to resolve...

jmelm93 avatar Dec 24 '24 01:12 jmelm93

Hi, @Owe1n. I'm Dosu, and I'm helping the langflow team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • The issue involves an error with the run_flow_from_json function due to missing parameters: session_id, sender, and sender_name.
  • The error is linked to the Tool Calling Agent node in Langflow version 1.1.0 on Mac OS.
  • Suggested solutions included providing the missing parameters and using a new "Agent" component, but these were not satisfactory.
  • A temporary workaround was found by removing the session_id check, though it's not a permanent fix.
  • Contributors @edwinjosechittilappilly and @elufowojud are working on a fix.

Next Steps:

  • Please confirm if this issue is still relevant to the latest version of the langflow repository. If so, you can keep the discussion open by commenting on the issue.
  • Otherwise, the issue will be automatically closed in 7 days.

Thank you for your understanding and contribution!

dosubot[bot] avatar Mar 25 '25 16:03 dosubot[bot]

Well?? Nothing on this? This is gaining importance since there are some companies trying to use LangFlow for production level solutions. And being able to run the flow on demand using a pure python script enable some ideas for CI and QA when it comes to agent and multi-agent systems' development.

Please, give some priority to this.

RaydelMiranda avatar Mar 26 '25 21:03 RaydelMiranda

Hi, @Owe1n. I'm Dosu, and I'm helping the langflow team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • You reported an error with the run_flow_from_json function in Langflow version 1.1.0 on Mac OS due to missing parameters: session_id, sender, and sender_name.
  • Suggestions were made to provide these parameters and use a new "Agent" component, but the issue persists.
  • The Simple Agent example fails when exporting with Python code.
  • A temporary workaround involves removing the session_id check, but it's not a permanent solution.
  • Contributors are actively working on a fix, highlighting the importance of resolving this for production-level solutions.

Next Steps:

  • Please let us know if this issue is still relevant to the latest version of the langflow repository by commenting here.
  • If no updates are provided, the issue will be automatically closed in 7 days.

Thank you for your understanding and contribution!

dosubot[bot] avatar Jun 25 '25 16:06 dosubot[bot]