refactor(agents): move error taxonomy to app/agents/shared/errors (slice 1)

First slice of promoting the shared agent toolkit out of the misnamed
`new_chat` package into the cross-agent `app/agents/shared` kernel.

`errors.py` is a leaf module (no intra-package deps) consumed by the
multi-agent chat, the chat streaming flows/monolith, and tests — i.e. it is
shared infrastructure, not single-agent code. Moved it verbatim to
`app.agents.shared.errors` and flipped all 12 importers. No re-export shim
remains since zero importers needed it.

Behavior-preserving: identical class/enum definitions; only the import path
changes. 1208 agent + chat-task tests green.
This commit is contained in:
CREDO23 2026-06-04 12:13:55 +02:00
parent a4010a357f
commit 0354f73f29
13 changed files with 13 additions and 13 deletions

View file

@ -11,7 +11,7 @@ from typing import Any
from langchain_core.messages import ToolMessage
from app.agents.new_chat.errors import StreamingError
from app.agents.shared.errors import StreamingError
from app.agents.new_chat.permissions import Rule

View file

@ -26,7 +26,7 @@ from langchain_core.messages import AIMessage, ToolMessage
from langchain_core.tools import BaseTool
from langgraph.runtime import Runtime
from app.agents.new_chat.errors import CorrectedError, RejectedError
from app.agents.shared.errors import CorrectedError, RejectedError
from app.agents.new_chat.permissions import Ruleset
from app.services.user_tool_allowlist import TrustedToolSaver

View file

@ -20,7 +20,7 @@ What this provides:
tools can poll to abort cooperatively. The event is reset between
turns. Tools should check ``runtime.context.cancel_event.is_set()``
in tight inner loops.
- A typed :class:`~app.agents.new_chat.errors.BusyError` raised when a
- A typed :class:`~app.agents.shared.errors.BusyError` raised when a
second turn arrives while the lock is held.
Note: SurfSense's ``stream_new_chat`` is the call site that should
@ -46,7 +46,7 @@ from langchain.agents.middleware.types import (
from langgraph.config import get_config
from langgraph.runtime import Runtime
from app.agents.new_chat.errors import BusyError
from app.agents.shared.errors import BusyError
logger = logging.getLogger(__name__)

View file

@ -50,7 +50,7 @@ from langchain_core.messages import AIMessage, ToolMessage
from langgraph.runtime import Runtime
from langgraph.types import interrupt
from app.agents.new_chat.errors import (
from app.agents.shared.errors import (
CorrectedError,
RejectedError,
StreamingError,

View file

@ -30,7 +30,7 @@ from app.agents.multi_agent_chat import create_multi_agent_chat_deep_agent
from app.agents.new_chat.chat_deepagent import create_surfsense_deep_agent
from app.agents.new_chat.checkpointer import get_checkpointer
from app.agents.new_chat.context import SurfSenseContextSchema
from app.agents.new_chat.errors import BusyError
from app.agents.shared.errors import BusyError
from app.agents.new_chat.filesystem_selection import FilesystemMode, FilesystemSelection
from app.agents.new_chat.llm_config import (
AgentConfig,

View file

@ -7,7 +7,7 @@ import logging
import time
from typing import Any, Literal
from app.agents.new_chat.errors import BusyError
from app.agents.shared.errors import BusyError
from app.agents.new_chat.middleware.busy_mutex import (
get_cancel_state,
is_cancel_requested,

View file

@ -14,7 +14,7 @@ import traceback
from collections.abc import Iterator
from typing import Any, Literal
from app.agents.new_chat.errors import BusyError
from app.agents.shared.errors import BusyError
from app.observability import metrics as ot_metrics, otel as ot
from app.services.new_streaming_service import VercelStreamingService
from app.tasks.chat.streaming.errors.classifier import classify_stream_exception

View file

@ -4,7 +4,7 @@ from __future__ import annotations
import pytest
from app.agents.new_chat.errors import BusyError
from app.agents.shared.errors import BusyError
from app.agents.new_chat.middleware.busy_mutex import (
BusyMutexMiddleware,
end_turn,

View file

@ -93,7 +93,7 @@ class TestPermissionMiddlewareIntegration:
def test_middleware_raises_interrupt_for_rm_in_desktop_mode(self) -> None:
from langchain_core.messages import AIMessage
from app.agents.new_chat.errors import RejectedError
from app.agents.shared.errors import RejectedError
mw = PermissionMiddleware(rulesets=[SURFSENSE_DEFAULTS, DESKTOP_SAFETY_RULESET])
# Stub the interrupt to a "reject" decision so we can assert the

View file

@ -5,7 +5,7 @@ from __future__ import annotations
import pytest
from langchain_core.messages import AIMessage, ToolMessage
from app.agents.new_chat.errors import CorrectedError, RejectedError
from app.agents.shared.errors import CorrectedError, RejectedError
from app.agents.new_chat.middleware.permission import (
PermissionMiddleware,
_normalize_permission_decision,

View file

@ -16,7 +16,7 @@ from typing import Any
import pytest
from app.agents.new_chat.errors import BusyError
from app.agents.shared.errors import BusyError
from app.agents.new_chat.middleware.busy_mutex import request_cancel, reset_cancel
from app.tasks.chat.stream_new_chat import (
_classify_stream_exception as old_classify,

View file

@ -7,7 +7,7 @@ from pathlib import Path
import pytest
import app.tasks.chat.stream_new_chat as stream_new_chat_module
from app.agents.new_chat.errors import BusyError
from app.agents.shared.errors import BusyError
from app.agents.new_chat.middleware.busy_mutex import request_cancel, reset_cancel
from app.tasks.chat.stream_new_chat import (
StreamResult,