open-swe/agent/utils/dashboard_handoff.py
Ramon Nogueira 92dbf6f932
fix: update Slack trace reply on web handoff (#1630)
* fix: update Slack trace reply on web handoff

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>

* fix: trigger web handoff on dashboard starts

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>

* fix: format web handoff as contextual fragment

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>

* fix: preserve trace_message_ts when overwriting Slack run mapping

When store_slack_run_mapping is called without trace_message_ts (e.g. on
follow-up Slack mentions), it was unconditionally overwriting the
thread-level mapping and clobbering the timestamp captured from the
initial trace reply. After that, _notify_slack_web_handoff could not find
the original message, so a subsequent move to Web silently skipped the
Slack trace update.

Now, when trace_message_ts is not passed, the existing thread mapping is
read first and its trace_message_ts is preserved.

* style: ruff format

---------

Co-authored-by: Ramon Nogueira <270434257+ramon-langchain@users.noreply.github.com>
Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
Co-authored-by: Johannes du Plessis <51395795+johannes117@users.noreply.github.com>
Co-authored-by: Johannes du Plessis <johannes@langchain.dev>
2026-06-29 10:22:01 -07:00

11 lines
587 B
Python

DASHBOARD_HANDOFF_OPEN_TAG = "<open_swe_web_handoff>"
DASHBOARD_HANDOFF_CLOSE_TAG = "</open_swe_web_handoff>"
DASHBOARD_HANDOFF_MARKER = DASHBOARD_HANDOFF_OPEN_TAG
DASHBOARD_HANDOFF_BODY = (
"This follow-up was sent from Web. The conversation has moved to Web, so answer in "
"the dashboard stream with a normal assistant message. Do not call slack_thread_reply "
"unless a later Slack message explicitly moves the conversation back to Slack."
)
DASHBOARD_HANDOFF_INSTRUCTION = (
f"{DASHBOARD_HANDOFF_OPEN_TAG}\n{DASHBOARD_HANDOFF_BODY}\n{DASHBOARD_HANDOFF_CLOSE_TAG}"
)