Skip to content

fix(telegram): prevent recovered tool failures from replacing final streamed replies#18909

Closed
JSchwerberg wants to merge 4 commits intoopenclaw:mainfrom
JSchwerberg:fix/17837-telegram-exec-warning
Closed

fix(telegram): prevent recovered tool failures from replacing final streamed replies#18909
JSchwerberg wants to merge 4 commits intoopenclaw:mainfrom
JSchwerberg:fix/17837-telegram-exec-warning

Conversation

@JSchwerberg
Copy link
Copy Markdown

@JSchwerberg JSchwerberg commented Feb 17, 2026

Summary

Describe the problem and fix in 2–5 bullets:

  • Problem: Telegram 2.15 draft streaming could leak intermediate exec/bash failure warnings after successful fallback, and in a specific streamed path the final answer could be dropped when message_end had tool-call-only content.
  • Why it matters: Users saw instability/noise (⚠️ Exec ... failed) or only tool-call artifacts instead of the recovered final answer.
  • What changed: Added streamed-reply-aware suppression for exec/bash warnings, preserved streamed assistant text when message_end has no text block, and added regressions for both behaviors.
  • What did NOT change (scope boundary): No changes to model fallback policy, no cross-channel formatting changes beyond existing shared payload/subscription logic.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

User-visible / Behavior Changes

  • Telegram users should no longer see intermediate exec/bash failure warnings when fallback succeeds and user-facing streamed output already exists.
  • In the affected 2.15 streaming path, final answer text is retained instead of being lost when message_end contains no text block.

Security Impact (required)

  • New permissions/capabilities? (Yes/No) No
  • Secrets/tokens handling changed? (Yes/No) No
  • New/changed network calls? (Yes/No) No
  • Command/tool execution surface changed? (Yes/No) No
  • Data access scope changed? (Yes/No) No
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: Linux (dev environment)
  • Runtime/container: Node 22+, pnpm 10, vitest
  • Model/provider: N/A (unit/e2e harness coverage)
  • Integration/channel (if any): Telegram draft-streaming path (test harness)
  • Relevant config (redacted): block-streaming disabled for Telegram draft stream path

Steps

  1. Stream assistant output to Telegram preview.
  2. Trigger an intermediate exec/bash failure and recover via fallback tool.
  3. End with a turn where message_end may include tool-call-only content.

Expected

  • Recovered final answer is delivered.
  • Intermediate exec/bash failure warning is suppressed in user-facing output when fallback succeeded.

Actual

  • Before fix: warning leaked and/or final answer could be dropped in this path.
  • After fix: warning suppressed (when appropriate) and final streamed text retained.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios:
    • pnpm vitest run --config vitest.e2e.config.ts src/agents/pi-embedded-runner/run/payloads.e2e.test.ts
    • pnpm vitest run src/telegram/bot-message-dispatch.test.ts
    • pnpm vitest run --config vitest.e2e.config.ts src/agents/pi-embedded-subscribe.subscribe-embedded-pi-session.does-not-emit-duplicate-block-replies-text.e2e.test.ts
  • Edge cases checked:
    • exec and bash warning suppression with streamed user-facing output.
    • streamed delta text retained when message_end carries no text block.
  • What you did not verify:
    • Live Telegram account/manual device run in production-like environment.

Compatibility / Migration

  • Backward compatible? (Yes/No) Yes
  • Config/env changes? (Yes/No) No
  • Migration needed? (Yes/No) No
  • If yes, exact upgrade steps:

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly:
    • Revert commits on this PR branch (4daa4d6f2, d9c095c7b) and redeploy.
  • Files/config to restore:
    • src/agents/pi-embedded-runner/run/payloads.ts
    • src/agents/pi-embedded-subscribe.handlers.messages.ts
    • src/agents/pi-embedded-subscribe.ts
  • Known bad symptoms reviewers should watch for:
    • ⚠️ Exec/Bash failed reappears before/alongside recovered final answer.
    • streamed answer preview appears but no final answer is delivered.

Risks and Mitigations

List only real risks for this PR. Add/remove entries as needed. If none, write None.

  • Risk:
    • Suppressing warnings could hide meaningful exec/bash failures in edge cases.
    • Mitigation:
      • Suppression is limited to cases where user-facing reply already exists; tests cover both show/suppress paths.
  • Risk:
    • Streamed-text retention fallback could duplicate text in some message-end shapes.
    • Mitigation:
      • Existing duplicate-avoidance logic remains; added targeted regression test for no-text message_end path.

AI Assistance

  • AI-assisted: Yes (Codex)
  • Testing level: Lightly tested with focused automated tests listed above.

@openclaw-barnacle openclaw-barnacle bot added channel: telegram Channel integration: telegram agents Agent runtime and tooling size: S labels Feb 17, 2026
@JSchwerberg JSchwerberg force-pushed the fix/17837-telegram-exec-warning branch 4 times, most recently from 22a84c6 to 6f23880 Compare February 17, 2026 17:28
@JSchwerberg JSchwerberg force-pushed the fix/17837-telegram-exec-warning branch from ea79256 to b2e9099 Compare February 18, 2026 00:14
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 size: S

Projects

None yet

1 participant