Skip to content
Open
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
19 changes: 9 additions & 10 deletions redbox/redbox/graph/nodes/sends.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import asyncio
import json
import logging
import threading
from concurrent.futures import ThreadPoolExecutor, TimeoutError, as_completed
from typing import Callable
from uuid import uuid4

from langchain_core.messages import AIMessage
from langchain_mcp_adapters.tools import load_mcp_tools
from langgraph.constants import Send

from redbox.models.chain import DocumentState, RedboxState, TaskStatus
from redbox.api.format import format_mcp_tool_response

import asyncio
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
from langchain_mcp_adapters.tools import load_mcp_tools
import json

from redbox.api.format import format_mcp_tool_response
from redbox.models.chain import DocumentState, RedboxState, TaskStatus
from redbox.models.file import ChunkCreatorType

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -270,6 +268,7 @@ def run_tools_parallel(

if response is None:
log.warning(f"{future_tool_name} Tool has failed or timed out")
response = f"{future_tool_name} Tool has failed or timed out"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add check for is_loop and if so set to appropriate tuple?

ie. response = ("Tool has failed or timed out", "fail", "False") if is_loop else "Tool..."

continue

log.warning("response not None")
Expand Down Expand Up @@ -329,17 +328,17 @@ def run_tools_parallel(
log.warning(
f"{log_stub} Every tool execution has failed or timed out after {per_tool_timeout} seconds."
)
return None
return "Tool has failed or timed out"

except TimeoutError:
log.warning(f"{log_stub} Global parallel tool execution timed out after {parallel_timeout} seconds.")
return None
return "Tool has timed out"
except Exception as e:
log.warning(
f"{log_stub} Unexpected error in parallel tool execution: {str(e)}",
exc_info=True,
)
return None
return "Tool has unexpected error"


def no_dependencies(dependencies: list[str], plan) -> bool:
Expand Down
Loading