Skip to content

fix(telegram): keep killed-session resume guidance task-scoped (#2109) - #2110

Merged
konard merged 3 commits into
mainfrom
issue-2109-a3152bc64438
Jul 27, 2026
Merged

fix(telegram): keep killed-session resume guidance task-scoped (#2109)#2110
konard merged 3 commits into
mainfrom
issue-2109-a3152bc64438

Conversation

@konard

@konard konard commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Fixes #2109.

Problem

A killed /codex task advertised 8b8e10af-0776-4706-aae6-72c95bebbd73 as resumable even though its actual Codex thread was 019f980e-a0fd-75e1-907b-9167319836ad.

The last real marker was about 3.99 MB before EOF. The completion monitor searched only the final 256 KiB, then selected the newest UUID-named log from start-command's shared Docker directory. That file belonged to another task. The retry therefore failed with no rollout found.

The monitor also rendered terminal solve syntax because immediate, queued, isolated-queued, and durable session paths did not preserve the actual Telegram alias.

Solution

  • scan each task's captured log backwards in bounded 256 KiB chunks, with overlap for markers split at a chunk boundary
  • stop using neighboring UUID-named files as a completion fallback because the backend directory is shared across tasks
  • omit resume guidance when no session ID can be attributed to the killed task
  • preserve commandAlias and original arguments through immediate execution, both queue backends, session tracking, and bot restarts
  • render /solve, /claude, or /codex according to the command the user actually sent
  • retain the old task-scoped directory helper for compatible callers, while documenting its ownership precondition
  • preserve the full sanitized incident evidence and analysis under docs/case-studies/issue-2109/

Reproduction and regression coverage

The production-shaped fixture creates:

  1. an execution log whose real Session ID marker is more than 256 KiB before EOF;
  2. an unrelated, newer UUID-named log beside it;
  3. a killed session launched through /codex; and
  4. a no-marker case that must not borrow the unrelated UUID.

Before the implementation, the focused suite failed all 14 original assertions: it selected the unrelated thread, emitted solve, and lost alias/argument context in every launch path.

tests/test-issue-2109-killed-resume.mjs now passes 18/18 assertions, including all requested Telegram aliases, queue/restart persistence, and a marker split at a scan boundary. Existing issue #1927 resume coverage also passes 31/31.

The resulting guidance for the reported task is attributable and Telegram-native:

/codex https://github.com/link-assistant/formal-ai/issues/845 --think xhigh --resume 019f980e-a0fd-75e1-907b-9167319836ad

Case study and research

Codex officially supports codex exec resume <SESSION_ID>. Similar upstream reports concern missing rollout materialization, but this incident is different: the first log proves that the advertised 8b8e… ID never belonged to the task, and the retry log proves Hive Mind supplied it. Codex rejected the unknown ID correctly, so no upstream issue was filed.

Incident screenshots

These are the two original Telegram states from the issue. The change affects generated notification content rather than layout; the post-fix notification text is verified through the real completion monitor in the automated regression above.

Killed task and invalid guidance Failed retry
Killed task Failed resume

Verification

  • Node 24 default suite — all 353 selected test files passed
  • issue --resume 8b8e10af-0776-4706-aae6-72c95bebbd73 failed #2109 focused regression — 18/18 passed
  • issue killed #1927 resume regression — 31/31 passed
  • full ESLint — passed
  • Prettier, MJS syntax, file-line limits, duplication threshold, changeset validation, documentation validation, and language synchronization — passed
  • origin/main is an ancestor of the final branch commits

Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: #2109
@konard konard self-assigned this Jul 27, 2026
@konard konard changed the title [WIP] --resume 8b8e10af-0776-4706-aae6-72c95bebbd73 failed fix(telegram): keep killed-session resume guidance task-scoped (#2109) Jul 27, 2026
@konard
konard marked this pull request as ready for review July 27, 2026 14:35
@konard

konard commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Working session summary

Implemented and finalized the fix for issue #2109.

  • Resume IDs now come only from the task’s own complete log, using bounded reverse scanning.
  • Removed unsafe shared-directory fallback.
  • Preserved /codex, /claude, and /solve aliases through queued, isolated, and durable paths.
  • Added an 18-case regression suite; it failed before the fix and passes afterward.
  • Added a sanitized case study with logs, screenshots, timeline, and research.
  • Full local validation and fresh GitHub CI passed on commit 7b66b586.
  • PR is merge-clean and ready for review.

No upstream Codex issue was filed: official Codex documentation confirms the resume syntax, while the evidence showed Hive Mind supplied an unrelated session ID.

PR: #2110


This summary was automatically extracted from the AI working session output.

@konard

konard commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Model: GPT-5.6 Sol
  • Provider: OpenAI
  • Public pricing estimate: $27.561656

📊 Context and tokens usage:

  • 580.6K / 200K (290%) input tokens, 59.9K / 128K (47%) output tokens

Total: (580.6K + 19.1M cached) input tokens, 59.9K output tokens, $27.561656 cost

🤖 Models used:

  • Tool: OpenAI Codex
  • Requested: gpt-5.6-sol
  • Thinking level: xhigh (~31999 tokens)
  • Model: GPT 5.6 Sol (gpt-5.6-sol)

📎 Log file uploaded as Gist (7178KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard

konard commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

✅ Ready to merge

This pull request is now ready to be merged:

  • All CI checks have passed
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

@konard
konard merged commit 74be87b into main Jul 27, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--resume 8b8e10af-0776-4706-aae6-72c95bebbd73 failed

1 participant