2 Commits

Author SHA1 Message Date
461343cf80 expand length of allowed responses before compacting 2026-05-24 18:08:49 -07:00
920b616468 bender 🔥 not 👀 2026-05-17 18:25:04 -07:00
2 changed files with 16 additions and 6 deletions

View File

@@ -122,7 +122,7 @@ def make_app(ws):
)
return
client.reactions_add(channel=channel, timestamp=message_ts, name="eyes")
client.reactions_add(channel=channel, timestamp=message_ts, name="fire")
try:
ws_logger.info("DeepSeek API call starting model=%s", deepseek_model)
@@ -176,10 +176,10 @@ def make_app(ws):
finally:
try:
client.reactions_remove(
channel=channel, timestamp=message_ts, name="eyes"
channel=channel, timestamp=message_ts, name="fire"
)
except Exception:
ws_logger.warning("Failed to remove eyes reaction", exc_info=True)
ws_logger.warning("Failed to remove fire reaction", exc_info=True)
return slack_app

View File

@@ -25,7 +25,12 @@ logger = logging.getLogger(__name__)
# Constants
# ---------------------------------------------------------------------------
DEEPSEEK_TIMEOUT = 120 # seconds
MAX_INLINE_LENGTH = 2800 # characters
MAX_INLINE_LENGTH = 10_000 # characters
def _has_code_snippet(text: str) -> bool:
"""Return True if the text contains a fenced code block."""
return "```" in text
MAX_TOOL_TURNS = 5 # max tool-call back-and-forths with DeepSeek
# ---------------------------------------------------------------------------
@@ -387,16 +392,21 @@ def make_app(ws):
reply_text = md_to_slack(reply_text)
if len(reply_text) <= MAX_INLINE_LENGTH:
if len(reply_text) <= MAX_INLINE_LENGTH and not _has_code_snippet(reply_text):
await say(text=reply_text, thread_ts=thread_ts)
else:
initial_comment = (
"The response contains a code snippet, which doesn't render well inline."
if _has_code_snippet(reply_text)
else "The response was too long for an inline message."
)
await client.files_upload_v2(
channel=channel,
thread_ts=thread_ts,
content=reply_text,
filename="response.txt",
title="DeepSeek Response",
initial_comment="The response was too long for an inline message.",
initial_comment=initial_comment,
)
except Exception as exc: