2020from common .config .app_config import config
2121from common .database .database_base import DatabaseBase
2222from common .models .messages import TeamConfiguration
23- from common .utils .markdown_utils import (
24- normalize_markdown_tables as _normalize_markdown_tables ,
25- reflow_collapsed_table_line as _reflow_collapsed_table_line ,
26- )
23+ from common .utils .markdown_utils import \
24+ normalize_markdown_tables as _normalize_markdown_tables
2725from models .messages import AgentMessageStreaming , WebsocketMessageType
2826from orchestration .connection_config import (connection_config ,
2927 orchestration_config )
3937apply_tool_history_leak_patch ()
4038
4139_BARE_IMAGE_URL_RE = re .compile (
42- r"(?<![\(\]])"
43- r"(?<!\]\()"
44- r"("
45- # Absolute image URL (any host, or a backend /api/v4/images path)
46- r"https?://[^\s)]+?(?:/api/v4/images/[^\s)]+?|[^\s)]+?\.(?:png|jpe?g|gif|webp))"
47- # Bare relative backend image path (emitted by the MCP/backend image tools).
48- # The (?<![^\s]) guard requires the path to start at whitespace/string-start so
49- # it never matches the same substring inside an absolute URL.
50- r"|(?<![^\s])/api/v4/images/[^\s)]+?\.(?:png|jpe?g|gif|webp)"
51- r")"
52- r"(?=[\s)\]]|$)" ,
53- re .IGNORECASE ,
40+ r"(?<![\(\]])"
41+ r"(?<!\]\()"
42+ r"("
43+ # Absolute image URL (any host, or a backend /api/v4/images path)
44+ r"https?://[^\s)]+?(?:/api/v4/images/[^\s)]+?|[^\s)]+?\.(?:png|jpe?g|gif|webp))"
45+ # Bare relative backend image path (emitted by the MCP/backend image tools).
46+ # The (?<![^\s]) guard requires the path to start at whitespace/string-start so
47+ # it never matches the same substring inside an absolute URL.
48+ r"|(?<![^\s])/api/v4/images/[^\s)]+?\.(?:png|jpe?g|gif|webp)"
49+ r")"
50+ r"(?=[\s)\]]|$)" ,
51+ re .IGNORECASE ,
5452)
5553
5654
@@ -222,25 +220,20 @@ async def get_current_or_new_orchestration(
222220 current is not None and current_team_id != team_config .team_id
223221 )
224222
225-
226223 cls .logger .info (
227224 "get_current_or_new_orchestration: user='%s' selected_team='%s' "
228225 "cached_team='%s' team_switched=%s team_changed=%s current_is_none=%s" ,
229226 user_id , team_config .team_id , current_team_id ,
230227 team_switched , team_changed , current is None ,
231228 )
232229
233-
234230 # Full rebuild: no workflow exists, team explicitly switched, or the
235231 # cached workflow belongs to a different team than the selected one.
236232 needs_full_rebuild = current is None or team_switched or team_changed
237233
238-
239234 # Lightweight reset: workflow finished but agents are still valid for the
240235 # same team (a team change always routes to full rebuild above so we
241236 # never reuse the previous team's agents here).
242-
243-
244237 needs_workflow_reset = not needs_full_rebuild and workflow_terminated
245238
246239 if needs_full_rebuild :
@@ -859,4 +852,4 @@ async def _process_event_stream(
859852 if tool_approvals :
860853 result ["tool_approvals" ] = tool_approvals
861854 return result
862- return None
855+ return None
0 commit comments