# Fallback reply contracts and live Telegram regressions

Status: implemented and verified in source and the freshly installed package.
Publishing and restarting the active bot remain user-owned. The subsequent
OpenCode-first capability ordering is tracked in
[its work order](WO-fallback-quality-order-20261012.md); Telegram progress
presentation remains explicitly deferred.

## User steering

The running cascade selects OpenCode Nemotron, Kilo Nemotron and Hermes but
reports `invalid_response`; OVH reports `empty_response`, and Big Pickle rejects
the request with HTTP 400. Handle the actual protocol and expected reply contract
dynamically for every selected fallback. Do not treat a successful isolated
provider probe as proof that production routing uses the same adapter.

The user also reported that replying to ordinary "good dog" chatter created and
uploaded `reply.txt`. Review current live logs and fix evidenced problems before
publication; preserve the ongoing full free-model coverage work.

## Evidence

The scoped public run `telegram-c34a3d7d53728329-1791861851684-1` began at
2026-10-13T03:24:12Z. It produced a plain reply, which the host rejected after a
semantic review demanded delivery evidence. The current criterion was
`effect:visible_response`; the current user message requested no file. That
rejection led to a failed file send, file creation, another blocked result check,
then a successful upload and an echoed final reply at 03:25:41Z. Eventual upload
success does not justify the invented delivery obligation.

The [sanitized prompt audit](evidence/native-conversation-prompt-audit-20261012.json)
also found generic zero-execution guidance that told the model to take a tool
action for a conversational goal. Tool receipt authority must remain intact;
ordinary conversation must not be required to manufacture execution evidence.

Current debug artifacts redact actual outbound requests and do not retain
auxiliary provider response bodies. The generic `invalid_response` category
combined transport JSON, native tool and structured-schema failures; that label
alone did not identify the cause. Production-helper probes with invented context
isolated it: the simple native-goal schema passed, but the full terminal-review
schema produced an HTTP 200 error envelope. The upstream Nvidia grammar rejected
`uniqueItems`, wrapped as `server_error`. See the [exact safe diagnostic
receipt](evidence/terminal-review-error-probe-20261012.json). No private message,
credential or raw provider response body is retained in the public receipts.

## Work and acceptance

1. Trace selected-model metadata through the actual production fallback helper,
   backend factory, request builder and response decoder. Select Chat Completions
   or Responses per model, preserve tool/schema/context contracts, and condition
   unsupported wire hints without weakening host validation.
2. Exercise the actual native-goal review policy and schema through these
   production adapters with invented conversation/evidence. Derive provider
   limits from their public catalogs. Use no local inference, real actions,
   Telegram messages or private human context. Honor quota cooldowns.
3. Add safe, precise rejection diagnostics identifying the expected reply kind
   and validation stage; never print raw bodies, secret values or user context.
   Validate structured auxiliary replies before exposing their text as a
   completed reply. Preserve Stop, ownership and no replay after visible output.
4. Repair evidenced conversational tool pressure and test a direct chat reply
   without files, uploads or fabricated tool receipts. Real mutation/delivery
   requests must retain actual effect and provider-acknowledgement requirements.
5. Run focused and production Telegram regressions, rebuild the package, verify
   the freshly installed artifact and record scoped commit/push receipts.

## Additional live checks

Review later runs for duplicate contradictory completion events and tool
description truncation. Apply only repairs supported by current evidence;
record unresolved observations explicitly instead of broadening the task into
unrelated runtime changes.

## Implementation and verification

- Normalize in-band provider errors before decoding Chat Completions or
  Responses, including HTTP 200 JSON and SSE envelopes. Retain only whitelisted
  failure categories and status, never upstream text or nested causes.
- Learn the proven native `uniqueItems` restriction per full endpoint path,
  model and API shape for five minutes. Retry that route once with a separately
  lowered wire schema. Preserve the complete original host schema, completion
  callback, tool parameters and uniqueness checks. Include original-schema
  guidance in the admitted request budget. Do not strip arbitrary constraints.
- Validate expected JSON and native tool calls before releasing structured
  replies or executable tool fragments. Accept one complete JSON fence without
  changing values; reject prose extraction, malformed arguments, unoffered
  calls, truncation and duplicate citations. Preserve cancellation, ownership,
  deadlines, manual fallback permission and the no-replay boundary after output.
- Distinguish JSON syntax, schema mismatch, unsupported schema, tool choice,
  tool arguments and transport envelope failures in safe route diagnostics.
- Remove generic pressure to manufacture tool execution for conversation.
  Preserve file-write/edit/send purpose before long scoped paths consume the
  model-facing description budget. Text replies need no fabricated reply file;
  requested material effects still require actual tool and delivery receipts.

Source verification: 520 orchestrator tests passed with one existing skip;
122 CLI tests passed. The complete workspace build and artifact audit passed.
The compiler-free fresh npm installation loaded SQLite and the CLI/library;
60 deterministic checks exercised the actual installed backend, including
12 full terminal-review grammar-repair/host-rejection cases.

The [post-repair live receipt](evidence/terminal-review-schema-repair-probe-20261012.json)
uses the actual production fallback helper and backend with synthetic context,
the unchanged full terminal-review schema and public provider limits. OpenCode
and Kilo both rejected the initial native grammar, then returned original-schema
valid JSON after the same-route repair. Kilo chose `deliver`; OpenCode chose
`stop`. OpenCode's generated justification was not retained, so semantic
correctness is not claimed. Hermes reached the adapted request and returned
HTTP 429; the probe stopped at its two-send quota. No local inference, Telegram
messages or tool actions occurred. Remote quota or outage can still exhaust a
bounded cascade; this repair does not promise perpetual service availability.

The later 03:28 run's successful handler result and failed synthetic terminal
projection are distinct events. The latter retained pending visible-response
acknowledgement. This observation does not establish a duplicate-handler bug or
justify weakening the delivery gate; presentation work remains queued in
[its work order](WO-telegram-progress-presentation-20261012.md).
