Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

feat(backend/copilot): let AutoPilot read the user's expert chats (#14424)

Reinier van der Leer11de34593868
diff --git a/autogpt_platform/backend/backend/copilot/baseline/service.py b/autogpt_platform/backend/backend/copilot/baseline/service.py
index 256300993b..051c5b5fda 100644
--- a/autogpt_platform/backend/backend/copilot/baseline/service.py
+++ b/autogpt_platform/backend/backend/copilot/baseline/service.py
@@ -79,6 +79,7 @@ from backend.copilot.pending_messages import (
from backend.copilot.prompting import (
SHARED_TOOL_NOTES,
get_delegation_supplement,
+ get_expert_oversight_supplement,
get_graphiti_supplement,
)
from backend.copilot.provider_failure import classify as classify_provider_failure
@@ -1876,6 +1877,9 @@ async def stream_chat_completion_baseline(
Flag.HIRE_EXPERTS, user_id, default=False
)
delegation_supplement = get_delegation_supplement() if experts_enabled else ""
+ oversight_supplement = get_expert_oversight_supplement(
+ experts_enabled=experts_enabled, expert_id=session.expert_id
+ )
# Append the builder-session block (graph id+name + full building guide)
# AFTER the shared supplements so the system prompt is byte-identical
# across turns of the same builder session — Claude's prompt cache keeps
@@ -1886,6 +1890,7 @@ async def stream_chat_completion_baseline(
base_system_prompt
+ SHARED_TOOL_NOTES
+ delegation_supplement
+ + oversight_supplement
+ graphiti_supplement
+ builder_session_suffix
+ expert_session_suffix
diff --git a/autogpt_platform/backend/backend/copilot/db.py b/autogpt_platform/backend/backend/copilot/db.py
index b17d728fb1..873ab05517 100644
--- a/autogpt_platform/backend/backend/copilot/db.py
+++ b/autogpt_platform/backend/backend/copilot/db.py
@@ -795,6 +795,7 @@ async def get_user_chat_sessions(
title_contains: str | None = None,
expert_id: str | None = None,
autopilot_only: bool = False,
+ experts_only: bool = False,
pinned_first: bool = True,
) -> list[ChatSessionInfo]:
"""Get chat sessions for a user, ordered by most recent.
@@ -810,17 +811,20 @@ async def get_user_chat_sessions(
without waiting on async embedding.
``expert_id`` restricts the listing to sessions scoped to that expert.
- ``autopilot_only`` restricts it to sessions whose ``expertId`` is NULL.
- The explicit flag is necessary because ``expert_id=None`` retains the
- existing meaning of "all expert scopes" for user-facing session lists.
+ ``autopilot_only`` restricts it to sessions whose ``expertId`` is NULL,
+ ``experts_only`` to those whose ``expertId`` is set. The explicit flags
+ are necessary because ``expert_id=None`` retains the existing meaning of
+ "all expert scopes" for user-facing session lists.
``pinned_first=False`` provides strict recency ordering for internal
adoption flows; the user-facing sidebar keeps pinned sessions first.
"""
if expert_id == "":
raise ValueError("expert_id must be non-empty")
- if expert_id is not None and autopilot_only:
- raise ValueError("expert_id and autopilot_only are mutually exclusive")
+ if sum((expert_id is not None, autopilot_only, experts_only)) > 1:
+ raise ValueError(
+ "expert_id, autopilot_only and experts_only are mutually exclusive"
+ )
params: list[Any] = [user_id]
conditions = ['"userId" = $1', _EXCLUDE_DREAM_SESSIONS_SQL]
@@ -840,9 +844,15 @@ async def get_user_chat_sessions(
conditions.append(f'"expertId" = ${len(params)}')
elif autopilot_only:
conditions.append('"expertId" IS NULL')
+ elif experts_only:
+ conditions.append('"expertId" IS NOT NULL')
params.extend((limit, offset))
+ # "id" breaks ties: without a total order, LIMIT/OFFSET paging can skip or
+ # repeat a row when two sessions share an updatedAt.
ordering = (
- '"isPinned" DESC, "updatedAt" DESC' if pinned_first else '"updatedAt" DESC'
+ '"isPinned" DESC, "updatedAt" DESC, "id" DESC'
+ if pinned_first
+ else '"updatedAt" DESC, "id" DESC'
)
query = (
'SELECT * FROM {schema_prefix}"ChatSession" WHERE '
diff --git a/autogpt_platform/backend/backend/copilot/db_session_listing_test.py b/autogpt_platform/backend/backend/copilot/db_session_listing_test.py
index ef60b5f2a9..ea8711dfb7 100644
--- a/autogpt_platform/backend/backend/copilot/db_session_listing_test.py
+++ b/autogpt_platform/backend/backend/copilot/db_session_listing_test.py
@@ -91,6 +91,22 @@ async def test_list_query_excludes_dreams_with_null_safe_operator():
assert raw.call_args.kwargs["model"] is PrismaChatSession
[email protected]("pinned_first", [True, False])
+async def test_list_ordering_is_total_so_offset_paging_cannot_skip_a_row(
+ pinned_first,
+):
+ """``isPinned``/``updatedAt`` alone leave ties in an arbitrary order, and
+ LIMIT/OFFSET over an arbitrary order can drop or repeat a session between
+ pages. The id makes the sort total."""
+ raw = AsyncMock(return_value=[])
+ with patch(_RAW_QUERY_TARGET, raw):
+ await get_user_chat_sessions("u1", pinned_first=pinned_first)
+
+ order_by = raw.call_args.args[0].split("ORDER BY")[1].split("LIMIT")[0]
+ assert order_by.strip().endswith('"id" DESC')
+
+
@pytest.mark.asyncio
async def test_list_query_maps_raw_rows_to_chat_session_info():
raw = AsyncMock(return_value=[_make_prisma_session("sess-42")])
@@ -142,6 +158,25 @@ async def test_autopilot_only_count_query_requires_null_expert_id():
assert raw.call_args.args[1:] == ("u1",)
+async def test_experts_only_list_query_requires_a_non_null_expert_id():
+ raw = AsyncMock(return_value=[])
+ with patch(_RAW_QUERY_TARGET, raw):
+ await get_user_chat_sessions("u1", experts_only=True)
+
+ query = raw.call_args.args[0]
+ assert '"expertId" IS NOT NULL' in query
+ assert raw.call_args.args[1:] == ("u1", 50, 0)
+
+
+async def test_experts_only_is_exclusive_with_both_other_scope_filters():
+ with pytest.raises(ValueError, match="mutually exclusive"):
+ await get_user_chat_sessions("u1", expert_id="expert-1", experts_only=True)
+ with pytest.raises(ValueError, match="mutually exclusive"):
+ await get_user_chat_sessions("u1", autopilot_only=True, experts_only=True)
+
+
@pytest.mark.asyncio
async def test_autopilot_only_and_expert_filter_are_mutually_exclusive():
with pytest.raises(ValueError, match="mutually exclusive"):
diff --git a/autogpt_platform/backend/backend/copilot/permissions.py b/autogpt_platform/backend/backend/copilot/permissions.py
index eb20b19160..846f023514 100644
--- a/autogpt_platform/backend/backend/copilot/permissions.py
+++ b/autogpt_platform/backend/backend/copilot/permissions.py
@@ -106,6 +106,7 @@ ToolName = Literal[
"hire_expert",
"list_agent_triggers",
"list_chat_platform_channels",
+ "list_expert_chats",
"list_folders",
"list_presets",
"list_schedules",
@@ -120,6 +121,7 @@ ToolName = Literal[
"move_folder",
"post_to_chat_platform",
"raise_expert",
+ "read_expert_chat",
"read_skill",
"read_workspace_file",
"run_agent",
diff --git a/autogpt_platform/backend/backend/copilot/prompting.py b/autogpt_platform/backend/backend/copilot/prompting.py
index b8e81737e6..15c5dfdde1 100644
--- a/autogpt_platform/backend/backend/copilot/prompting.py
+++ b/autogpt_platform/backend/backend/copilot/prompting.py
@@ -696,6 +696,28 @@ def get_delegation_supplement() -> str:
"""
+def get_expert_oversight_supplement(
+ *, experts_enabled: bool, expert_id: str | None
+) -> str:
+ """Chat-reading rules, for an Autopilot session with the team flag on.
+
+ Gated here rather than at the call sites so the condition lives with
+ the text it admits. It cannot ride ``get_delegation_supplement``, which
+ both sides of a delegation see: these tools are in the ``expert_admin``
+ group, so an expert session's ``execute_tool`` refuses them and naming
+ them would only advertise a refusal.
+ """
+ if not experts_enabled or expert_id:
+ return ""
+ return """
+
+### Reading a teammate's chats
+`list_expert_chats` then `read_expert_chat` answer "what did <expert> do or
+say". The transcript pages newest-first — ask for the window you need, not
+the whole chat.
+"""
+
+
def get_graphiti_supplement() -> str:
"""Get the memory system instructions to append when Graphiti is enabled.
diff --git a/autogpt_platform/backend/backend/copilot/prompting_test.py b/autogpt_platform/backend/backend/copilot/prompting_test.py
index d05b708d84..1c296182f9 100644
--- a/autogpt_platform/backend/backend/copilot/prompting_test.py
+++ b/autogpt_platform/backend/backend/copilot/prompting_test.py
@@ -99,3 +99,32 @@ class TestGraphitiMemoryScope:
assert "Memory is private and isolated to the current assistant" in result
assert "cannot read each other's memories" in result
assert "Memory is private to this user — no other user can see it" not in result
+
+
+class TestExpertOversightSupplement:
+ """The chat-reading tools are in the ``expert_admin`` group, so only an
+ Autopilot session with the team flag on can call them — a turn that
+ cannot must not be told about them."""
+
+ def test_an_autopilot_turn_with_the_flag_on_names_both_tools(self):
+ result = prompting.get_expert_oversight_supplement(
+ experts_enabled=True, expert_id=None
+ )
+ assert "list_expert_chats" in result
+ assert "read_expert_chat" in result
+
+ def test_an_expert_session_is_told_nothing(self):
+ assert (
+ prompting.get_expert_oversight_supplement(
+ experts_enabled=True, expert_id="expert-a"
+ )
+ == ""
+ )
+
+ def test_the_flag_off_tells_nobody(self):
+ assert (
+ prompting.get_expert_oversight_supplement(
+ experts_enabled=False, expert_id=None
+ )
+ == ""
+ )
diff --git a/autogpt_platform/backend/backend/copilot/sdk/building_mode_restart_test.py b/autogpt_platform/backend/backend/copilot/sdk/building_mode_restart_test.py
index 1ad7e04c66..61edfaa207 100644
--- a/autogpt_platform/backend/backend/copilot/sdk/building_mode_restart_test.py
+++ b/autogpt_platform/backend/backend/copilot/sdk/building_mode_restart_test.py
@@ -77,6 +77,7 @@ class TestApplyBuildingModeRestart:
prior_emitted: bool = False,
thinking_reprompted: bool = False,
delegation_supplement: str = "",
+ oversight_supplement: str = "",
):
from backend.copilot.sdk.service import (
_BUILDING_MODE_CONTINUATION,
@@ -98,6 +99,7 @@ class TestApplyBuildingModeRestart:
sdk_options=sdk_options,
base_system_prompt="BASE",
delegation_supplement=delegation_supplement,
+ oversight_supplement=oversight_supplement,
graphiti_supplement="",
use_e2b=False,
session_id="sess-1",
@@ -120,21 +122,20 @@ class TestApplyBuildingModeRestart:
assert "building mode" in status.message.lower()
@pytest.mark.asyncio
- async def test_delegation_supplement_survives_the_restart(self, mocker):
+ @pytest.mark.parametrize("supplement", ["delegation", "oversight"])
+ async def test_supplements_survive_the_restart(self, mocker, supplement):
"""The restart rebuilds the system prompt from its own parts.
- Tool registration happened once, before it, so the delegation tools
- stay callable for the rest of the turn — dropping their disclosure
- rules here is exactly the silent-delegation hole
- ``get_delegation_supplement`` exists to close.
+ Tool registration happened once, before it, so both tool groups stay
+ callable for the rest of the turn — dropping their disclosure rules
+ here is exactly the silent-delegation hole these supplements close.
"""
- _, state, _, _ = await self._run(
- mocker, delegation_supplement="\n\n<delegation>RULES</delegation>"
- )
+ marker = f"<{supplement}>RULES</{supplement}>"
+ _, state, _, _ = await self._run(mocker, **{f"{supplement}_supplement": marker})
prompt = state.options.system_prompt
text = prompt if isinstance(prompt, str) else prompt["append"]
- assert "<delegation>RULES</delegation>" in text
+ assert marker in text
@pytest.mark.asyncio
async def test_empty_suffix_degrades_without_prompt_upgrade(self, mocker):
@@ -185,6 +186,7 @@ class TestApplyBuildingModeRestart:
sdk_options=MagicMock(),
base_system_prompt="BASE",
delegation_supplement="",
+ oversight_supplement="",
graphiti_supplement="",
use_e2b=False,
session_id="sess-1",
diff --git a/autogpt_platform/backend/backend/copilot/sdk/service.py b/autogpt_platform/backend/backend/copilot/sdk/service.py
index 13d9bede16..31e757fff2 100644
--- a/autogpt_platform/backend/backend/copilot/sdk/service.py
+++ b/autogpt_platform/backend/backend/copilot/sdk/service.py
@@ -116,6 +116,7 @@ from ..permissions import (
)
from ..prompting import (
get_delegation_supplement,
+ get_expert_oversight_supplement,
get_graphiti_supplement,
get_sdk_supplement,
)
@@ -1694,6 +1695,7 @@ async def _apply_building_mode_restart(
sdk_options: "ClaudeAgentOptions",
base_system_prompt: str,
delegation_supplement: str,
+ oversight_supplement: str,
graphiti_supplement: str,
use_e2b: bool,
session_id: str,
@@ -1722,14 +1724,16 @@ async def _apply_building_mode_restart(
organization_id=session.organization_id,
team_id=session.team_id,
)
- # Same supplement order as the main assembly. The delegation tools stay
- # registered across a restart (registration happens once, before it), so
- # dropping their disclosure rules here would leave the model able to
- # delegate silently for the rest of the turn.
+ # Same supplement order as the main assembly. The delegation and
+ # chat-reading tools stay registered across a restart (registration happens
+ # once, before it), so dropping their disclosure rules here would leave the
+ # model able to delegate, or read a teammate's chats, silently for the rest
+ # of the turn.
system_prompt = (
base_system_prompt
+ get_sdk_supplement(use_e2b=use_e2b)
+ delegation_supplement
+ + oversight_supplement
+ graphiti_supplement
+ building_suffix
+ expert_session_suffix
@@ -4787,6 +4791,9 @@ async def stream_chat_completion_sdk( # pyright: ignore[reportGeneralTypeIssues
Flag.HIRE_EXPERTS, user_id, default=False
)
delegation_supplement = get_delegation_supplement() if experts_enabled else ""
+ oversight_supplement = get_expert_oversight_supplement(
+ experts_enabled=experts_enabled, expert_id=session.expert_id
+ )
# Append the builder-session block (graph id+name + full building
# guide) AFTER the shared supplements so the system prompt is
# byte-identical across turns of the same builder session — Claude's
@@ -4802,6 +4809,7 @@ async def stream_chat_completion_sdk( # pyright: ignore[reportGeneralTypeIssues
base_system_prompt
+ get_sdk_supplement(use_e2b=use_e2b)
+ delegation_supplement
+ + oversight_supplement
+ graphiti_supplement
+ builder_session_suffix
+ expert_session_suffix
@@ -5570,6 +5578,7 @@ async def stream_chat_completion_sdk( # pyright: ignore[reportGeneralTypeIssues
sdk_options=sdk_options,
base_system_prompt=base_system_prompt,
delegation_supplement=delegation_supplement,
+ oversight_supplement=oversight_supplement,
graphiti_supplement=graphiti_supplement,
use_e2b=use_e2b,
session_id=session_id,
diff --git a/autogpt_platform/backend/backend/copilot/tools/__init__.py b/autogpt_platform/backend/backend/copilot/tools/__init__.py
index e56266dd05..1d9aa03409 100644
--- a/autogpt_platform/backend/backend/copilot/tools/__init__.py
+++ b/autogpt_platform/backend/backend/copilot/tools/__init__.py
@@ -25,6 +25,7 @@ from .decompose_goal import DecomposeGoalTool
from .delegate_to_expert import DelegateToExpertTool
from .edit_agent import EditAgentTool
from .enter_building_mode import EnterAgentBuildingModeTool
+from .expert_chats import ListExpertChatsTool, ReadExpertChatTool
from .feature_requests import CreateFeatureRequestTool, SearchFeatureRequestsTool
from .find_agent import FindAgentTool
from .find_block import FindBlockTool
@@ -174,6 +175,10 @@ TOOL_REGISTRY: dict[str, BaseTool] = {
"update_expert": UpdateExpertTool(),
"confirm_expert_change": ConfirmExpertChangeTool(),
"handoff_to_expert": HandoffToExpertTool(),
+ # Reading a teammate's chats (Autopilot sessions only): the user's
+ # own data, read with the query the chat API uses.
+ "list_expert_chats": ListExpertChatsTool(),
+ "read_expert_chat": ReadExpertChatTool(),
}
# Export individual tool instances for backwards compatibility
@@ -201,14 +206,16 @@ TOOL_GROUPS: dict[str, ToolGroup] = {
# A handoff transfers a task between experts, so it needs a caller with
# an expert identity to hand it off from.
"handoff_to_expert": "experts",
- # Staffing the team is the user's call, made in the Autopilot chat — an
- # expert must not hire its own teammates. The engines disable this
- # group whenever the session HAS an expert_id (the opposite gate to
- # ``experts`` above).
+ # Oversight of the team is the user's, exercised in the Autopilot chat:
+ # an expert must not hire its own teammates, and must not read another
+ # expert's chats. The engines disable this group whenever the session
+ # HAS an expert_id (the opposite gate to ``experts`` above).
"hire_expert": "expert_admin",
"raise_expert": "expert_admin",
"update_expert": "expert_admin",
"confirm_expert_change": "expert_admin",
+ "list_expert_chats": "expert_admin",
+ "read_expert_chat": "expert_admin",
# Delegation works from either side of ``session.expert_id`` (AutoPilot
# and expert sessions alike), so it has its own group: the engines
# disable it only when the user's hire-experts flag is off.
diff --git a/autogpt_platform/backend/backend/copilot/tools/expert_chats.py b/autogpt_platform/backend/backend/copilot/tools/expert_chats.py
new file mode 100644
index 0000000000..dd63a2c4d4
--- /dev/null
+++ b/autogpt_platform/backend/backend/copilot/tools/expert_chats.py
@@ -0,0 +1,409 @@
+"""Read the user's chats with their hired experts — AutoPilot only, never writes.
+
+An expert's chat is the user's own data, but it lives outside the AutoPilot
+thread and nothing in the session context carries it. These two tools give
+AutoPilot the read the user already has in the UI: the same paginated query,
+so the same ownership check, and the same hidden-row and injected-context
+filtering the chat API applies before rendering.
+"""
+
+import logging
+from typing import Any
+
+from backend.copilot.expert_kickoff import is_hidden_chat_message
+from backend.copilot.model import ChatMessage, ChatSession
+from backend.copilot.service import strip_injected_context_for_display
+from backend.data.db_accessors import chat_db, experts_db
+from backend.util.truncate import truncate
+
+from .base import BaseTool
+from .models import (
+ ErrorResponse,
+ ExpertChatListResponse,
+ ExpertChatMessage,
+ ExpertChatSummary,
+ ExpertChatTranscriptResponse,
+ ToolResponseBase,
+)
+
+logger = logging.getLogger(__name__)
+
+_MAX_LIMIT = 50
+_DEFAULT_LIMIT = 20
+
+# Two budgets, because a single transcript row can be a 95K tool result: the
+# page cap bounds what one call costs the turn, the row cap stops one row
+# from spending the whole page. Keep the row cap well under the page cap so
+# a page always holds several messages.
+_MAX_PAGE_CHARS = 8_000
+_MAX_MESSAGE_CHARS = 2_000
+
+# Same wording for "no such chat" and "belongs to someone else", so the tool
+# is not an existence oracle for session ids.
+_NOT_FOUND = (
+ "No expert chat with id {session_id}. Call list_expert_chats for the ids "
+ "you can read."
+)
+
+
+class ListExpertChatsTool(BaseTool):
+ """List the user's chats with their hired experts."""
+
+ @property
+ def name(self) -> str:
+ return "list_expert_chats"
+
+ @property
+ def requires_auth(self) -> bool:
+ return True
+
+ @property
+ def description(self) -> str:
+ return (
+ "List the user's chats with their hired experts, most recently "
+ "updated first. Pass expert_id to see one expert's chats only. "
+ "Returns session ids for read_expert_chat; never returns message "
+ "content."
+ )
+
+ @property
+ def parameters(self) -> dict[str, Any]:
+ return {
+ "type": "object",
+ "properties": {
+ "expert_id": {
+ "type": "string",
+ "description": (
+ "Only chats with this expert. Omit for every expert. "
+ "Ids come from list_team or <team_context>."
+ ),
+ },
+ "limit": {
+ "type": "integer",
+ "description": f"Chats to return (max {_MAX_LIMIT}).",
+ "default": _DEFAULT_LIMIT,
+ },
+ "offset": {
+ "type": "integer",
+ "description": "Chats to skip, for paging.",
+ "default": 0,
+ },
+ },
+ }
+
+ async def _execute(
+ self,
+ user_id: str | None,
+ session: ChatSession,
+ *,
+ expert_id: str | None = None,
+ limit: int = _DEFAULT_LIMIT,
+ offset: int = 0,
+ **kwargs,
+ ) -> ToolResponseBase:
+ if user_id is None:
+ return ErrorResponse(
+ message="Authentication required", session_id=session.session_id
+ )
+
+ one_expert = (expert_id or "").strip() or None
+ page_size = _clamp(limit, _DEFAULT_LIMIT)
+ start = max(0, offset or 0)
+ try:
+ # One row past the page, so a full page can say whether it is the
+ # last one rather than costing a call to find out.
+ chats = await chat_db().get_user_chat_sessions(
+ user_id,
+ page_size + 1,
+ start,
+ organization_id=session.organization_id,
+ expert_id=one_expert,
+ # Mutually exclusive with expert_id, which already implies it.
+ experts_only=one_expert is None,
+ )
+ except Exception as e:
+ logger.warning(f"list_expert_chats lookup failed: {e}")
+ return ErrorResponse(
+ message="Could not load the expert chats right now. Try again.",
+ session_id=session.session_id,
+ )
+
+ has_more = len(chats) > page_size
+ chats = chats[:page_size]
+
+ names = await _expert_names(user_id)
+ if not chats:
+ who = names.get(one_expert, one_expert) if one_expert else "any expert"
+ return ExpertChatListResponse(
+ message=f"No chats with {who} yet.",
+ session_id=session.session_id,
+ )
+
+ rows = [
+ ExpertChatSummary(
+ session_id=chat.session_id,
+ # experts_only / expert_id guarantee a non-null expertId.
+ expert_id=chat.expert_id or "",
+ expert_name=names.get(chat.expert_id or ""),
+ title=chat.title,
+ updated_at=chat.updated_at,
+ )
+ for chat in chats
+ ]
+ listing = "; ".join(
+ f"{row.expert_name or row.expert_id} — "
+ f"{row.title or 'untitled'} "
+ f"(session_id: {row.session_id}, "
+ f"updated {row.updated_at:%Y-%m-%d})"
+ for row in rows
+ )
+ next_offset = start + len(rows) if has_more else None
+ more = (
+ f" More chats follow — pass offset {next_offset} for the next page."
+ if next_offset is not None
+ else ""
+ )
+ return ExpertChatListResponse(
+ message=(
+ f"{len(rows)} expert chat{'s' if len(rows) != 1 else ''}: "
+ f"{listing}. Read one with read_expert_chat.{more}"
+ ),
+ session_id=session.session_id,
+ chats=rows,
+ has_more=has_more,
+ next_offset=next_offset,
+ )
+
+
+class ReadExpertChatTool(BaseTool):
+ """Read a window of one expert chat."""
+
+ @property
+ def name(self) -> str:
+ return "read_expert_chat"
+
+ @property
+ def requires_auth(self) -> bool:
+ return True
+
+ @property
+ def description(self) -> str:
+ return (
+ "Read one of the user's chats with a hired expert, newest "
+ "messages first. Ids come from list_expert_chats. Walk back "
+ "through a long chat by passing the returned "
+ "next_before_sequence; ask for the window you need rather than "
+ "the whole chat."
+ )
+
+ @property
+ def parameters(self) -> dict[str, Any]:
+ return {
+ "type": "object",
+ "properties": {
+ "session_id": {
+ "type": "string",
+ "description": "Chat id from list_expert_chats.",
+ },
+ "before_sequence": {
+ "type": "integer",
+ "description": (
+ "Return messages older than this sequence. Omit for "
+ "the newest ones; then pass back the response's "
+ "next_before_sequence to page further back."
+ ),
+ },
+ "limit": {
+ "type": "integer",
+ "description": (
+ f"Messages to fetch (max {_MAX_LIMIT}). Fewer are "
+ f"returned when they exceed the {_MAX_PAGE_CHARS:,}"
+ "-character budget."
+ ),
+ "default": _DEFAULT_LIMIT,
+ },
+ "include_tool_results": {
+ "type": "boolean",
+ "description": (
+ "Include the expert's raw tool output. Off by "
+ "default: tool calls are already named on the "
+ "assistant message, and their results are bulky."
+ ),
+ "default": False,
+ },
+ },
+ "required": ["session_id"],
+ }
+
+ async def _execute(
+ self,
+ user_id: str | None,
+ session: ChatSession,
+ *,
+ session_id: str = "",
+ before_sequence: int | None = None,
+ limit: int = _DEFAULT_LIMIT,
+ include_tool_results: bool = False,
+ **kwargs,
+ ) -> ToolResponseBase:
+ if user_id is None:
+ return ErrorResponse(
+ message="Authentication required", session_id=session.session_id
+ )
+ chat_id = (session_id or "").strip()
+ if not chat_id:
+ return ErrorResponse(
+ message="session_id is required",
+ session_id=session.session_id,
+ )
+
+ try:
+ page = await chat_db().get_chat_messages_paginated(
+ chat_id,
+ _clamp(limit, _DEFAULT_LIMIT),
+ before_sequence,
+ # The ownership check: a chat owned by anyone else, or one
+ # outside the caller's org scope, comes back as None.
+ user_id=user_id,
+ organization_id=session.organization_id,
+ )
+ except Exception as e:
+ logger.warning(f"read_expert_chat lookup failed for {chat_id}: {e}")
+ return ErrorResponse(
+ message="Could not load that chat right now. Try again.",
+ session_id=session.session_id,
+ )
+
+ # Both are excluded from list_expert_chats, so reject them here too —
+ # otherwise fetch-by-id is a way around the listing's scope.
+ if (
+ page is None
+ or page.session.expert_id is None
+ or page.session.metadata.kind == "dream"
+ ):
+ return ErrorResponse(
+ message=_NOT_FOUND.format(session_id=chat_id),
+ session_id=session.session_id,
+ )
+
+ rendered = [
+ message
+ for message in (
+ _render(m, include_tool_results=include_tool_results)
+ for m in page.messages
+ )
+ if message is not None
+ ]
+ kept, over_budget = _fit_budget(rendered)
+ has_more = page.has_more or over_budget
+ next_cursor = kept[0].sequence if kept else page.oldest_sequence
+
+ expert_name = await _expert_name(user_id, page.session.expert_id)
+ title = page.session.title or "untitled"
+ if not kept:
+ summary = f"No readable messages in {expert_name}'s chat “{title}”."
+ else:
+ summary = (
+ f"{len(kept)} message{'s' if len(kept) != 1 else ''} from "
+ f"{expert_name}'s chat “{title}”, oldest first "
+ f"(sequences {kept[0].sequence}–{kept[-1].sequence})."
+ )
+ if has_more and next_cursor is not None:
+ summary += (
+ " Older messages remain — call read_expert_chat again with "
+ f"before_sequence={next_cursor}."
+ )
+ elif kept:
+ summary += " This is the start of the chat."
+
+ return ExpertChatTranscriptResponse(
+ message=summary,
+ session_id=session.session_id,
+ chat_session_id=chat_id,
+ expert_id=page.session.expert_id,
+ expert_name=expert_name,
+ title=page.session.title,
+ messages=kept,
+ has_more=has_more,
+ next_before_sequence=next_cursor,
+ )
+
+
+def _clamp(value: int | None, default: int) -> int:
+ return max(1, min(value if value is not None else default, _MAX_LIMIT))
+
+
+def _render(
+ message: ChatMessage, *, include_tool_results: bool
+) -> ExpertChatMessage | None:
+ """Project one persisted row into what the user sees, or None to skip it.
+
+ Mirrors the chat API's own read path: control turns the UI hides stay
+ hidden, and the server-injected ``<…_context>`` prefixes are stripped
+ from user rows.
+ """
+ if message.sequence is None or is_hidden_chat_message(message.metadata):
+ return None
+ if message.role == "tool" and not include_tool_results:
+ return None
+ if message.role not in ("user", "assistant", "tool"):
+ return None
+
+ content = message.content or ""
+ if message.role == "user":
+ content = strip_injected_context_for_display(content)
+ if message.role == "assistant" and message.tool_calls:
+ names = ", ".join(
+ (call.get("function") or {}).get("name") or call.get("name") or "?"
+ for call in message.tool_calls
+ )
+ content = f"{content}\n[called: {names}]".strip()
+ if not content.strip():
+ return None
+
+ return ExpertChatMessage(
+ sequence=message.sequence,
+ role=message.role,
+ content=truncate(content, _MAX_MESSAGE_CHARS),
+ created_at=message.created_at,
+ )
+
+
+def _fit_budget(
+ messages: list[ExpertChatMessage],
+) -> tuple[list[ExpertChatMessage], bool]:
+ """Keep the newest messages that fit ``_MAX_PAGE_CHARS``, oldest dropped first.
+
+ Dropping from the old end is what keeps paging lossless: the caller's
+ next cursor is the oldest row it actually received, so the dropped rows
+ are the first thing the next page returns.
+ """
+ kept: list[ExpertChatMessage] = []
+ spent = 0
+ for message in reversed(messages):
+ spent += len(message.content)
+ if spent > _MAX_PAGE_CHARS and kept:
+ return kept, True
+ kept.insert(0, message)
+ return kept, False
+
+
+async def _expert_names(user_id: str) -> dict[str, str]:
+ """Expert id → name, so a listing reads as a person rather than a uuid."""
+ try:
+ experts = await experts_db().list_experts(user_id, with_metrics=False)
+ except Exception as e:
+ logger.warning(f"expert roster lookup failed: {e}")
+ return {}
+ return {expert.id: expert.name for expert in experts}
+
+
+async def _expert_name(user_id: str, expert_id: str) -> str:
+ try:
+ expert = await experts_db().get_expert(
+ user_id, expert_id, include_workflows=False
+ )
+ except Exception as e:
+ logger.warning(f"expert lookup failed for {expert_id}: {e}")
+ return expert_id
+ return expert.name if expert else expert_id
diff --git a/autogpt_platform/backend/backend/copilot/tools/expert_chats_test.py b/autogpt_platform/backend/backend/copilot/tools/expert_chats_test.py
new file mode 100644
index 0000000000..d4b2a39179
--- /dev/null
+++ b/autogpt_platform/backend/backend/copilot/tools/expert_chats_test.py
@@ -0,0 +1,370 @@
+"""Tests for list_expert_chats / read_expert_chat (Autopilot reads an expert's chats).
+
+The capability is one-directional and read-only, so what is tested here is
+mostly what the tools refuse: an expert session never sees them and is turned
+away if it names one anyway, another user's chat is indistinguishable from one
+that does not exist, and a chat outside the listing's scope (Autopilot's own,
+a dream artifact) cannot be reached by id. The rest pins the paging contract —
+the character cap drops rows from the OLD end so the cursor it reports brings
+them back.
+
+``_FakeChatDB`` reproduces the one behaviour the ownership check rests on:
+``get_chat_messages_paginated`` puts ``user_id`` in the ChatSession
+where-clause, so a foreign caller gets ``None``. A mock that ignored it would
+make the ownership tests pass with the check deleted.
+"""
+
+from __future__ import annotations
+
+from datetime import UTC, datetime
+from unittest.mock import AsyncMock, MagicMock, patch
+
+import pytest
+
+from backend.copilot.db import PaginatedMessages
+from backend.copilot.model import ChatMessage, ChatSessionInfo, ChatSessionMetadata
+from backend.copilot.tools import (
+ TOOL_GROUPS,
+ execute_tool,
+ get_available_tools,
+ get_tool,
+)
+
+from .expert_chats import _MAX_PAGE_CHARS, ListExpertChatsTool, ReadExpertChatTool
+from .models import ErrorResponse, ExpertChatListResponse, ExpertChatTranscriptResponse
+
+_NOW = datetime(2026, 9, 7, 12, 0, tzinfo=UTC)
+
+
+def _caller(session_id: str = "s1", expert_id: str | None = None) -> MagicMock:
+ """The Autopilot session the tool is called from."""
+ session = MagicMock()
+ session.session_id = session_id
+ session.expert_id = expert_id
+ session.organization_id = None
+ return session
+
+
+def _chat(
+ session_id: str = "chat-1",
+ *,
+ user_id: str = "alice",
+ expert_id: str | None = "expert-a",
+ title: str | None = "Q3 research",
+ kind: str = "normal",
+) -> ChatSessionInfo:
+ return ChatSessionInfo(
+ session_id=session_id,
+ user_id=user_id,
+ title=title,
+ usage=[],
+ started_at=_NOW,
+ updated_at=_NOW,
+ metadata=ChatSessionMetadata(kind=kind),
+ expert_id=expert_id,
+ )
+
+
+def _msg(
+ sequence: int,
+ role: str = "assistant",
+ content: str | None = "hello",
+ **kwargs,
+) -> ChatMessage:
+ return ChatMessage(
+ role=role, content=content, sequence=sequence, created_at=_NOW, **kwargs
+ )
+
+
+class _FakeChatDB:
+ """The two query behaviours the tools depend on, ownership included."""
+
+ def __init__(
+ self,
+ chats: list[ChatSessionInfo] | None = None,
+ messages: list[ChatMessage] | None = None,
+ ) -> None:
+ self.chats = chats if chats is not None else [_chat()]
+ self.messages = messages or []
+ self.list_calls: list[dict] = []
+
+ async def get_user_chat_sessions(self, user_id, limit, offset, **kwargs):
+ self.list_calls.append({"user_id": user_id, "limit": limit, **kwargs})
+ rows = [c for c in self.chats if c.user_id == user_id]
+ if expert_id := kwargs.get("expert_id"):
+ rows = [c for c in rows if c.expert_id == expert_id]
+ elif kwargs.get("experts_only"):
+ rows = [c for c in rows if c.expert_id is not None]
+ return rows[offset : offset + limit]
+
+ async def get_chat_messages_paginated(
+ self,
+ session_id,
+ limit=50,
+ before_sequence=None,
+ user_id=None,
+ organization_id=None,
+ ):
+ chat = next((c for c in self.chats if c.session_id == session_id), None)
+ # Mirrors db.py: ``user_id``, when given, is part of the session
+ # where-clause — a chat owned by anyone else is simply not found.
+ if chat is None or (user_id is not None and chat.user_id != user_id):
+ return None
+ rows = [
+ m
+ for m in self.messages
+ if before_sequence is None or (m.sequence or 0) < before_sequence
+ ]
+ window = rows[-limit:] if limit else rows
+ return PaginatedMessages(
+ messages=window,
+ has_more=len(window) < len(rows),
+ oldest_sequence=window[0].sequence if window else None,
+ session=chat,
+ )
+
+
+def _experts(*pairs: tuple[str, str]) -> MagicMock:
+ roster = []
+ for expert_id, name in pairs:
+ expert = MagicMock()
+ expert.id = expert_id
+ expert.name = name
+ roster.append(expert)
+ client = MagicMock()
+ client.list_experts = AsyncMock(return_value=roster)
+ client.get_expert = AsyncMock(return_value=roster[0] if roster else None)
+ return MagicMock(return_value=client)
+
+
+def _patches(db: _FakeChatDB, *pairs: tuple[str, str]):
+ return (
+ patch("backend.copilot.tools.expert_chats.chat_db", MagicMock(return_value=db)),
+ patch(
+ "backend.copilot.tools.expert_chats.experts_db",
+ _experts(*(pairs or (("expert-a", "Ada"),))),
+ ),
+ )
+
+
+async def _read(db: _FakeChatDB, **kwargs):
+ chat_patch, experts_patch = _patches(db)
+ with chat_patch, experts_patch:
+ return await ReadExpertChatTool()._execute(
+ "alice", _caller(), session_id="chat-1", **kwargs
+ )
+
+
+async def _list(db: _FakeChatDB, **kwargs):
+ chat_patch, experts_patch = _patches(db)
+ with chat_patch, experts_patch:
+ return await ListExpertChatsTool()._execute("alice", _caller(), **kwargs)
+
+
+class TestGating:
+ """Autopilot-only: the tools ride the ``expert_admin`` group, which the
+ engines disable for every expert session."""
+
+ def test_both_tools_are_in_the_autopilot_only_group(self) -> None:
+ assert TOOL_GROUPS["list_expert_chats"] == "expert_admin"
+ assert TOOL_GROUPS["read_expert_chat"] == "expert_admin"
+
+ def test_an_autopilot_session_is_offered_them_and_an_expert_session_is_not(
+ self,
+ ) -> None:
+ autopilot = {t["function"]["name"] for t in get_available_tools()}
+ # What survives the filter, NOT what it hid — naming this `hidden`
+ # invites "fixing" the assertion below into its own inverse.
+ expert = {
+ t["function"]["name"]
+ for t in get_available_tools(disabled_groups=["expert_admin"])
+ }
+ assert {"list_expert_chats", "read_expert_chat"} <= autopilot
+ assert not {"list_expert_chats", "read_expert_chat"} & expert
+
+ @pytest.mark.parametrize("tool_name", ["list_expert_chats", "read_expert_chat"])
+ @pytest.mark.asyncio
+ async def test_an_expert_session_naming_the_tool_is_refused_before_dispatch(
+ self, tool_name: str
+ ) -> None:
+ tool = get_tool(tool_name)
+ assert tool is not None
+ with patch.object(
+ tool, "execute", new=AsyncMock(return_value="should never run")
+ ) as execute_mock:
+ result = await execute_tool(
+ tool_name=tool_name,
+ parameters={"session_id": "chat-1"},
+ user_id="alice",
+ session=_caller(expert_id="expert-a"),
+ tool_call_id="call-1",
+ disabled_groups=["expert_admin"],
+ )
+ execute_mock.assert_not_awaited()
+ assert result.success is False
+ assert ErrorResponse.model_validate_json(result.output).error == "tool_disabled"
+
+
+class TestListExpertChats:
+ @pytest.mark.asyncio
+ async def test_listing_without_an_expert_id_asks_for_expert_chats_only(
+ self,
+ ) -> None:
+ db = _FakeChatDB(chats=[_chat(), _chat("chat-2", expert_id=None)])
+ result = await _list(db)
+ assert isinstance(result, ExpertChatListResponse)
+ assert db.list_calls[0]["experts_only"] is True
+ assert [c.session_id for c in result.chats] == ["chat-1"]
+
+ @pytest.mark.asyncio
+ async def test_an_expert_id_filters_and_never_pairs_with_experts_only(
+ self,
+ ) -> None:
+ db = _FakeChatDB(chats=[_chat(), _chat("chat-2", expert_id="expert-b")])
+ result = await _list(db, expert_id="expert-b")
+ assert db.list_calls[0]["expert_id"] == "expert-b"
+ # The two are mutually exclusive in the query; passing both raises.
+ assert db.list_calls[0]["experts_only"] is False
+ assert [c.session_id for c in result.chats] == ["chat-2"]
+
+ @pytest.mark.asyncio
+ async def test_rows_carry_the_expert_name_not_just_the_id(self) -> None:
+ result = await _list(_FakeChatDB())
+ assert result.chats[0].expert_name == "Ada"
+ assert "Ada" in result.message
+
+ @pytest.mark.asyncio
+ async def test_another_users_chats_are_never_listed(self) -> None:
+ db = _FakeChatDB(chats=[_chat("chat-9", user_id="mallory")])
+ result = await _list(db)
+ assert result.chats == []
+
+
+class TestListPaging:
+ """A full page is only distinguishable from the last page by the row
+ fetched past it, so both cases are asserted against the same page size."""
+
+ @staticmethod
+ def _db(count: int) -> _FakeChatDB:
+ return _FakeChatDB(chats=[_chat(f"chat-{i}") for i in range(count)])
+
+ @pytest.mark.asyncio
+ async def test_a_full_page_with_more_behind_it_offers_the_next_offset(
+ self,
+ ) -> None:
+ result = await _list(self._db(3), limit=2)
+ assert [c.session_id for c in result.chats] == ["chat-0", "chat-1"]
+ assert result.has_more is True
+ assert result.next_offset == 2
+ assert "offset 2" in result.message
+
+ @pytest.mark.asyncio
+ async def test_the_offered_offset_returns_the_rest_and_stops(self) -> None:
+ result = await _list(self._db(3), limit=2, offset=2)
+ assert [c.session_id for c in result.chats] == ["chat-2"]
+ assert result.has_more is False
+ assert result.next_offset is None
+
+ @pytest.mark.asyncio
+ async def test_a_full_page_that_is_the_last_page_offers_nothing(self) -> None:
+ result = await _list(self._db(2), limit=2)
+ assert len(result.chats) == 2
+ assert result.has_more is False
+ assert result.next_offset is None
+ assert "More chats follow" not in result.message
+
+
+class TestReadOwnership:
+ @pytest.mark.asyncio
+ async def test_another_users_chat_reads_exactly_like_a_missing_one(self) -> None:
+ foreign = await _read(_FakeChatDB(chats=[_chat(user_id="mallory")]))
+ missing = await _read(_FakeChatDB(chats=[]))
+ assert isinstance(foreign, ErrorResponse)
+ assert foreign.message == missing.message
+
+ @pytest.mark.asyncio
+ async def test_the_callers_user_id_reaches_the_query(self) -> None:
+ """The ownership check IS that argument — pin it, not just its effect."""
+ db = _FakeChatDB(messages=[_msg(1)])
+ seen: dict = {}
+ original = db.get_chat_messages_paginated
+
+ async def spy(*args, **kwargs):
+ seen.update(kwargs)
+ return await original(*args, **kwargs)
+
+ db.get_chat_messages_paginated = spy # type: ignore[method-assign]
+ await _read(db)
+ assert seen["user_id"] == "alice"
+
+ @pytest.mark.asyncio
+ async def test_an_autopilot_chat_cannot_be_reached_by_id(self) -> None:
+ result = await _read(_FakeChatDB(chats=[_chat(expert_id=None)]))
+ assert isinstance(result, ErrorResponse)
+
+ @pytest.mark.asyncio
+ async def test_a_dream_session_cannot_be_reached_by_id(self) -> None:
+ result = await _read(_FakeChatDB(chats=[_chat(kind="dream")]))
+ assert isinstance(result, ErrorResponse)
+
+
+class TestReadRendering:
+ @pytest.mark.asyncio
+ async def test_it_shows_what_the_user_sees_and_hides_what_they_do_not(
+ self,
+ ) -> None:
+ db = _FakeChatDB(
+ messages=[
+ # The trailing blank line is part of the injected shape the
+ # production regex anchors on, not test decoration.
+ _msg(1, "user", "<user_context>secret</user_context>\n\nreal question"),
+ _msg(2, "user", "kickoff", metadata={"hidden": True}),
+ _msg(3, "tool", '{"bulk": "output"}', tool_call_id="c1"),
+ _msg(
+ 4,
+ "assistant",
+ "on it",
+ tool_calls=[{"function": {"name": "run_agent"}}],
+ ),
+ ]
+ )
+ result = await _read(db)
+ assert isinstance(result, ExpertChatTranscriptResponse)
+ assert [m.sequence for m in result.messages] == [1, 4]
+ assert result.messages[0].content == "real question"
+ assert "[called: run_agent]" in result.messages[1].content
+
+ @pytest.mark.asyncio
+ async def test_tool_output_is_available_on_request(self) -> None:
+ db = _FakeChatDB(messages=[_msg(1, "tool", "bulk", tool_call_id="c1")])
+ result = await _read(db, include_tool_results=True)
+ assert [m.sequence for m in result.messages] == [1]
+
+
+class TestReadPaging:
+ def _long_chat(self) -> _FakeChatDB:
+ return _FakeChatDB(messages=[_msg(i, content="x" * 2_500) for i in range(1, 6)])
+
+ @pytest.mark.asyncio
+ async def test_the_cap_drops_the_oldest_rows_and_reports_them_as_more(
+ self,
+ ) -> None:
+ result = await _read(self._long_chat())
+ assert sum(len(m.content) for m in result.messages) <= _MAX_PAGE_CHARS
+ assert [m.sequence for m in result.messages] == [3, 4, 5]
+ assert result.has_more is True
+ assert result.next_before_sequence == 3
+
+ @pytest.mark.asyncio
+ async def test_the_reported_cursor_brings_the_dropped_rows_back(self) -> None:
+ db = self._long_chat()
+ first = await _read(db)
+ older = await _read(db, before_sequence=first.next_before_sequence)
+ assert [m.sequence for m in older.messages] == [1, 2]
+ assert older.has_more is False
+
+ @pytest.mark.asyncio
+ async def test_a_short_chat_says_so_instead_of_offering_a_cursor(self) -> None:
+ result = await _read(_FakeChatDB(messages=[_msg(1), _msg(2)]))
+ assert result.has_more is False
+ assert "start of the chat" in result.message
diff --git a/autogpt_platform/backend/backend/copilot/tools/models.py b/autogpt_platform/backend/backend/copilot/tools/models.py
index d34a892c44..aef3d6bc49 100644
--- a/autogpt_platform/backend/backend/copilot/tools/models.py
+++ b/autogpt_platform/backend/backend/copilot/tools/models.py
@@ -128,6 +128,8 @@ class ResponseType(str, Enum):
EXPERT_CHANGE_PROPOSED = "expert_change_proposed"
EXPERT_CHANGE_APPLIED = "expert_change_applied"
TEAM_ROSTER = "team_roster"
+ EXPERT_CHAT_LIST = "expert_chat_list"
+ EXPERT_CHAT_TRANSCRIPT = "expert_chat_transcript"
# Base response model
@@ -619,6 +621,56 @@ class TeamRosterResponse(ToolResponseBase):
experts: list[TeamExpertInfo] = Field(default_factory=list)
+class ExpertChatSummary(BaseModel):
+ """One chat row returned by ``list_expert_chats``."""
+
+ session_id: str
+ expert_id: str
+ expert_name: str | None = None
+ title: str | None = None
+ updated_at: datetime
+
+
+class ExpertChatListResponse(ToolResponseBase):
+ """The user's chats with their hired experts, most recent first.
+
+ ``next_offset`` is the cursor for the next page, set only when one
+ exists: a full page is otherwise indistinguishable from the last one.
+ """
+
+ type: ResponseType = ResponseType.EXPERT_CHAT_LIST
+ chats: list[ExpertChatSummary] = Field(default_factory=list)
+ has_more: bool = False
+ next_offset: int | None = None
+
+
+class ExpertChatMessage(BaseModel):
+ """One transcript row returned by ``read_expert_chat``."""
+
+ sequence: int
+ role: str
+ content: str
+ created_at: datetime | None = None
+
+
+class ExpertChatTranscriptResponse(ToolResponseBase):
+ """A window of one expert chat, newest page first.
+
+ ``next_before_sequence`` is the cursor for the next (older) page; it is
+ the oldest row actually returned, which is not the oldest row fetched
+ whenever the character cap dropped rows from the old end.
+ """
+
+ type: ResponseType = ResponseType.EXPERT_CHAT_TRANSCRIPT
+ chat_session_id: str
+ expert_id: str
+ expert_name: str | None = None
+ title: str | None = None
+ messages: list[ExpertChatMessage] = Field(default_factory=list)
+ has_more: bool = False
+ next_before_sequence: int | None = None
+
+
class ExpertChangeProposedResponse(ToolResponseBase):
"""Preview returned by ``hire_expert`` / ``raise_expert`` — never a write.
diff --git a/autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py b/autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py
index e1b3e21e09..413c2e2492 100644
--- a/autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py
+++ b/autogpt_platform/backend/backend/copilot/tools/tool_schema_test.py
@@ -119,6 +119,13 @@ from backend.copilot.tools import TOOL_REGISTRY
# PRs add 1,763) rather than against whatever sits on dev today, because each
# branch's CI only ever sees its own delta. Registry measures 62,747 with all
# ten merged; 2,253 headroom.
+# list_expert_chats / read_expert_chat (SECRT-2581) add 1,706 chars and fit
+# under 65_000 without a bump of their own; merged registry measures 62,694.
+#
+# ON CONFLICT, KEEP THE HIGHER VALUE. Two branches tuning this line independently
+# both look correct: each one's CI only measures its own delta against dev, while
+# the budget has to cover what every in-flight PR adds together. Taking the
+# incoming side lowers a ceiling that has already ejected a green PR.
_CHAR_BUDGET = 65_000
diff --git a/autogpt_platform/frontend/src/app/api/openapi.json b/autogpt_platform/frontend/src/app/api/openapi.json
index 0625b25979..d7b737cf37 100644
--- a/autogpt_platform/frontend/src/app/api/openapi.json
+++ b/autogpt_platform/frontend/src/app/api/openapi.json
@@ -26334,7 +26334,9 @@
"expert_soul_updated",
"expert_change_proposed",
"expert_change_applied",
- "team_roster"
+ "team_roster",
+ "expert_chat_list",
+ "expert_chat_transcript"
],
"title": "ResponseType",
"description": "Types of tool responses."