Skip to content

Preserve session context and durable Telegram progress#84828

Closed
ooiuuii wants to merge 1 commit into
openclaw:release/2026.5.19from
ooiuuii:agent/xiaozhua/yoyou-519-telegram-context
Closed

Preserve session context and durable Telegram progress#84828
ooiuuii wants to merge 1 commit into
openclaw:release/2026.5.19from
ooiuuii:agent/xiaozhua/yoyou-519-telegram-context

Conversation

@ooiuuii

@ooiuuii ooiuuii commented May 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • preserve larger configured/session context windows over smaller runtime metadata when provider/model match
  • keep Telegram progress mode durable by sending tool progress as standalone messages instead of draft/edit previews
  • update Telegram dispatch tests for durable progress behavior on the 2026.5.19 release base

Test

  • ./node_modules/.bin/vitest run src/agents/session-context-tokens.test.ts src/agents/command/session-store.test.ts extensions/telegram/src/bot-message-dispatch.test.ts --maxWorkers=1

Real behavior proof

  • Behavior or issue addressed: Windows/Telegram OpenClaw 2026.5.19 was shrinking an explicitly configured 1050k session back to runtime-reported 272k after a successful agent run, and Telegram progress mode hid tool/progress updates in a repeatedly edited draft message instead of leaving durable 5.3-style progress messages.

  • Real environment tested: Real Windows/ROG OpenClaw gateway running OpenClaw 2026.5.19 (a185ca2) on port 18889, with the real Telegram channel enabled and reporting ON/OK. The Mac controller verified Windows gateway/control surfaces over the LAN/Tailscale dashboard path.

  • Exact steps or command run after this patch: Applied the equivalent Windows dist hotfix, restarted the Windows OpenClaw Gateway, checked /health, ran a real openclaw agent --agent main ... command against the Windows runtime, inspected C:\Users\Administrator\.openclaw\agents\main\sessions\sessions.json, checked recent runtime logs for schema/API errors, and exercised the real Windows Telegram bot path with a tool-progress turn.

  • Evidence after fix: Copied live output / redacted runtime evidence from the real setup:

    Windows Gateway http://127.0.0.1:18889/health: live
    OpenClaw version: 2026.5.19 (a185ca2)
    Telegram channel: ON/OK
    Agent smoke command: returned OK
    agent:main:main.sessionId == agent:main:telegram:default:direct:8589344021.sessionId
    shared sessionId: 6f44523c-fc48-49da-925d-bc8bc1e9f224
    agent:main:main.contextTokens: 1050000
    agent:main:telegram:default:direct:8589344021.contextTokens: 1050000
    verbose: full
    toolProgressDetail: raw
    recent logs: no new provider schema/API errors
    Mac cross-access checks after patch: 18898=200, 18913=200, 18912=200
    Telegram behavior after patch: tool/progress messages remained visible as standalone durable messages instead of being hidden in a repeatedly edited draft.
    
  • Observed result after fix: After the agent run, both main and Telegram direct sessions stayed aligned on the same session id with contextTokens=1050000, verbose=full, and toolProgressDetail=raw; the UI/status context no longer reflected the runtime-reported 272k value; Telegram progress/tool output remained durable and visible.

  • What was not tested: Full upstream CI on every package was not run locally; the PR relies on GitHub CI for full-matrix coverage. Production deployment was not tested.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram agents Agent runtime and tooling size: M triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 21, 2026
@clawsweeper

clawsweeper Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge.

Workflow note: Future ClawSweeper reviews update this same comment in place.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

Summary
The PR preserves larger session context-token values across agent runs and changes Telegram progress mode from an edited progress draft to standalone durable progress messages, with related tests.

Reproducibility: yes. by source inspection: the PR path spreads deliveryBaseOptions into standalone progress delivery, current deliverReplies mirrors when transcriptMirror is present, and the new context helper takes the max of runtime and fallback context tokens. I did not run tests or live Telegram because this review is read-only.

PR rating
Overall: 🧂 unranked krab
Proof: 🐚 platinum hermit
Patch quality: 🧂 unranked krab
Summary: The proof signal is usable, but the patch is not quality-ready because the current diff has blocking message-delivery and session-state defects.

Rank-up moves:

  • Fix the transcript mirroring, label-only progress, and stale fallback context-token issues with focused regression tests.
  • After code changes, refresh the real Telegram proof with a redacted transcript, recording, live output, or logs that show durable progress behavior and session context preservation.
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Real behavior proof
Sufficient (live_output): The PR body includes copied live output from a real Windows gateway with Telegram enabled and session context checks; a Telegram Desktop recording would still help review the visible message-order semantics after fixes.

Mantis proof suggestion
A Telegram Desktop proof would show whether progress messages are durable, ordered correctly, absent from transcript context, and compatible with toolProgress=false. A maintainer can ask Mantis to capture proof by posting a new PR comment that starts with the OpenClaw Mantis account mention, followed by:

telegram desktop proof: verify progress-mode Telegram tool updates stay visible, do not enter transcript context, and preserve toolProgress=false behavior.

Risk before merge

  • Merging as-is can mirror standalone Telegram progress/status messages into the durable assistant transcript, changing future model context.
  • Existing Telegram users with streaming.mode="progress" would move from one editable status draft to multiple standalone chat messages without a compatibility path or docs update.
  • Existing streaming.progress.toolProgress=false setups would lose their label-only progress indicator instead of keeping a quiet status draft until final delivery.
  • The context-token resolver can keep an older larger session context window after a provider/model switch because fallback context tokens are included in the max calculation regardless of model match.

Maintainer options:

  1. Fix semantics before merge (recommended)
    Patch standalone progress so non-final status messages never mirror into transcripts, preserve label-only progress mode, constrain context-token preservation to matching runtime model/provider or explicit config, and refresh real Telegram proof after the fixes.
  2. Accept a documented progress policy change
    Maintainers can intentionally make progress messages durable by default, but should update Telegram docs/config hints and provide upgrade proof for existing progress-mode settings before landing.
  3. Split session context from progress transport
    If durable Telegram progress needs more design, land a narrower session-context PR and leave Telegram progress transport unchanged for now.

Next step before merge
Human review is needed because the PR intentionally changes Telegram progress UX and needs author/maintainer revisions rather than an automated cleanup-only repair.

Security
Cleared: No dependency, workflow, permission, credential, or supply-chain changes were introduced; the blockers are functional delivery and session-state correctness.

Review findings

  • [P1] Stop mirroring standalone progress into transcripts — extensions/telegram/src/bot-message-dispatch.ts:1196
  • [P1] Preserve label-only progress mode — extensions/telegram/src/bot-message-dispatch.ts:681
  • [P1] Do not carry stale context windows across model switches — src/agents/session-context-tokens.ts:72
Review details

Best possible solution:

Keep the session-context fix narrow, make durable Telegram progress an explicit documented policy or opt-in mode, and preserve transcript hygiene plus existing progress configuration semantics before merge.

Do we have a high-confidence way to reproduce the issue?

Yes, by source inspection: the PR path spreads deliveryBaseOptions into standalone progress delivery, current deliverReplies mirrors when transcriptMirror is present, and the new context helper takes the max of runtime and fallback context tokens. I did not run tests or live Telegram because this review is read-only.

Is this the best way to solve the issue?

No. The session-context goal is valid, but the current patch is not the safest solution because it changes Telegram progress policy, transcript behavior, and context-window preservation too broadly.

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes copied live output from a real Windows gateway with Telegram enabled and session context checks; a Telegram Desktop recording would still help review the visible message-order semantics after fixes.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body includes copied live output from a real Windows gateway with Telegram enabled and session context checks; a Telegram Desktop recording would still help review the visible message-order semantics after fixes.
  • remove status: 📣 needs proof: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P2: This is a focused bug/improvement PR with real user impact, but the remaining blockers are bounded to Telegram progress delivery and session context metadata.
  • merge-risk: 🚨 compatibility: The PR changes documented progress-mode behavior for existing Telegram configs from an edited draft to standalone visible messages.
  • merge-risk: 🚨 message-delivery: The new standalone progress path can send extra Telegram messages and does not yet preserve the existing label-only progress delivery semantics.
  • merge-risk: 🚨 session-state: The new context-token resolver can preserve stale larger context windows across model/provider changes, affecting compaction and session status.
  • rating: 🧂 unranked krab: Current PR rating is 🧂 unranked krab because proof is 🐚 platinum hermit, patch quality is 🧂 unranked krab, and The proof signal is usable, but the patch is not quality-ready because the current diff has blocking message-delivery and session-state defects.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body includes copied live output from a real Windows gateway with Telegram enabled and session context checks; a Telegram Desktop recording would still help review the visible message-order semantics after fixes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes copied live output from a real Windows gateway with Telegram enabled and session context checks; a Telegram Desktop recording would still help review the visible message-order semantics after fixes.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The PR changes visible Telegram progress-message behavior, which is well suited to a short Telegram Desktop proof recording.

Full review comments:

  • [P1] Stop mirroring standalone progress into transcripts — extensions/telegram/src/bot-message-dispatch.ts:1196
    deliveryBaseOptions includes transcriptMirror, and deliverReplies mirrors every delivered payload when that callback is present. Sending standalone tool/progress updates through this helper will append non-final status text to the assistant transcript, so future turns can see tool labels or progress chatter as model context; clear transcriptMirror for non-final progress or use a non-transcript delivery path.
    Confidence: 0.96
  • [P1] Preserve label-only progress mode — extensions/telegram/src/bot-message-dispatch.ts:681
    With streaming.progress.toolProgress: false, streamToolProgressVisible is false and this branch returns before displaying anything. Current docs/config hints and tests keep a label-only progress draft for that setting, so existing users would lose their visible progress indicator instead of only hiding tool lines.
    Confidence: 0.93
  • [P1] Do not carry stale context windows across model switches — src/agents/session-context-tokens.ts:72
    The helper always includes fallbackContextTokens in the Math.max candidate set, and callers pass the active session entry's context window as that fallback. After switching from a larger old model to a smaller runtime-reported model, the old larger value still wins even when provider/model no longer match, which can overstate context and compaction state.
    Confidence: 0.91

Overall correctness: patch is incorrect
Overall confidence: 0.92

Acceptance criteria:

  • node scripts/run-vitest.mjs src/agents/session-context-tokens.test.ts src/agents/command/session-store.test.ts src/auto-reply/reply/session.test.ts extensions/telegram/src/bot-message-dispatch.test.ts
  • Real Telegram proof for progress-mode delivery after fixes, with private IDs/tokens/endpoints redacted

What I checked:

  • PR patch: The fetched PR patch for head dd6b47b adds standalone Telegram progress delivery and a new resolvePreservedSessionContextTokens helper across session persistence paths. (dd6b47b97e68)
  • Maintainer Telegram decision: The Telegram maintainer note says streaming owns one visible preview message and Telegram transport/streaming PRs need real Telegram proof; that makes this progress-mode behavior change upgrade-sensitive rather than a routine refactor. (.agents/maintainer-notes/telegram.md:7, 8284c035a096)
  • Current documented behavior: Current Telegram docs say progress mode keeps one editable status draft for tool progress, clears it at completion, and sends the final answer as a normal message. Public docs: docs/channels/telegram.md. (docs/channels/telegram.md:314, 8284c035a096)
  • Transcript mirror path: Current dispatch options carry transcriptMirror in deliveryBaseOptions, and deliverReplies mirrors delivered content whenever that callback is supplied; the PR's standalone progress helper spreads those options without clearing transcriptMirror. (extensions/telegram/src/bot-message-dispatch.ts:1015, 8284c035a096)
  • Existing label-only progress coverage: Current tests and config hints cover progress.toolProgress=false as label-only progress draft behavior; the PR deletes those expectations and suppresses output instead. (extensions/telegram/src/bot-message-dispatch.test.ts:1859, 8284c035a096)
  • Session context provenance: Current context-token selection in agent-runner was introduced in the provider-qualified session context limits fix, so fallback context values are part of the relevant session-state history. (src/auto-reply/reply/agent-runner.ts:1599, 2645ed154b42)

Likely related people:

  • steipete: git blame and release-base history tie the current Telegram streaming/progress code, docs, and tests to commits c8a953a and a185ca2. (role: recent area contributor; confidence: high; commits: c8a953af9371, a185ca283a74; files: extensions/telegram/src/bot-message-dispatch.ts, extensions/telegram/src/bot-message-dispatch.test.ts, docs/channels/telegram.md)
  • neeravmakwana: The provider-qualified session context limit work in 2645ed1 touched the same agent-runner fallback context-token path affected by this PR. (role: session context limits contributor; confidence: medium; commits: 2645ed154b42; files: src/auto-reply/reply/agent-runner.ts, src/auto-reply/reply/followup-runner.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 8284c035a096.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels May 21, 2026
@clawsweeper

clawsweeper Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🔥 Warming up: real-behavior proof passed; findings, security review, or rank-up moves are still in progress.

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.
What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@ooiuuii ooiuuii force-pushed the agent/xiaozhua/yoyou-519-telegram-context branch from d4b2793 to dd6b47b Compare May 21, 2026 06:02
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 21, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels May 21, 2026
@ooiuuii

ooiuuii commented May 21, 2026

Copy link
Copy Markdown
Contributor Author

Closing this for now: this branch is intended as a personal fork customization for durable Telegram progress behavior rather than a proposed upstream default. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: telegram Channel integration: telegram mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant