Skip to content

fix(macos): harden shared chat and PTT agent continuity - #9660

Merged
Git-on-my-level merged 8 commits into
BasedHardware:mainfrom
Git-on-my-level:codex/qa-chat-regressions-main-20260713
Jul 14, 2026
Merged

Git-on-my-level merged 8 commits into
BasedHardware:mainfrom
Git-on-my-level:codex/qa-chat-regressions-main-20260713

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Jul 13, 2026 •

Copy link
Copy Markdown
Member

Summary

  • make typed chat and push-to-talk share one canonical agent timeline and authorized context across reconnects, barge-ins, provider failures, and repeated turns
  • separate realtime transport readiness from context-bound input admission so buffered audio cannot enter a provider on a stale or missing seed
  • make journal persistence independently owned per continuity key and preserve the visible failed/interrupted turn before terminal cleanup
  • require realtime background-agent launches to return one compact durable child session/run/attempt lifecycle and send only its bounded semantic result to the provider
  • make semantic background_agent / delegated_agent discovery resolve durable leaf sessions across concrete UI surfaces, with bounded result payloads
  • extend the standing agent/voice harness so these race, continuity, spawn, and child-result regressions fail deterministically before manual QA

Root cause and durable guard

Oracle review identified one split-authority failure class rather than model forgetfulness. A connected socket was treated as context-ready, hubDidConnect could open provider input without a turn-specific admission, a global persistence generation allowed turn B to invalidate turn A's receipt, provider failure cleared local transcript state before creating a journal obligation, and a parent spawn receipt could be accepted without a matching durable child lifecycle.

The durable guard is now fail-closed: physical transport readiness only triggers context preparation; buffered audio is admitted only when the exact current snapshot identity is bound to the active logical turn. Journal obligations and receipts are keyed by continuity identity, provider failures capture before terminalization, and realtime spawn success requires a matching compact child plus provider semantic digest. The production policies are exercised through deterministic continuation/race tests and are included in agent-logic-harness.sh.

The OpenClaw final-output failure had a second concrete boundary mismatch: the realtime model asked for semantic background_agent / delegated_agent surfaces, while child runs are persisted under concrete surfaces such as floating_bar. Exact filtering returned no child; merely removing the filter let a newer coordinator win limit: 1. The runtime now maps those semantic hints to executionRole = leaf, preserves recent-first ordering, caps session-list tool output, and returns the durable child final text without exposing internal IDs. A regression test creates a newer coordinator beside the child and proves limit: 1 still returns the leaf result.

Verification

  • make setup — refreshed origin/main and installed linked-worktree-safe hooks
  • git diff --check — passed
  • cd desktop/macos && ./scripts/agent-logic-harness.sh --swift-only — focused voice lifecycle, context admission, persistence race, and spawn-contract suites passed
  • cd desktop/macos && ./scripts/agent-logic-harness.sh --node-only — agent runtime and pi-mono extension suites passed
  • cd desktop/macos/agent && npm test -- control-tools.test.ts omi-tool-manifest.test.ts — 95 tests passed
  • pre-push manifest — 530 agent runtime tests, 104 pi-mono tests, generated surfaces, and clean Swift compile passed
  • cd desktop/macos && ./scripts/agent-continuity-gauntlet.sh --port 47919 --bundle-id com.omi.omi-main-qa --suite continuity --turn-timeout-ms 45000 — typed -> PTT -> PTT recall -> typed recall passed
  • live OpenClaw handoff — PTT spawned a child returning OPENCLAW-HANDOFF-FINAL; the immediate next PTT turn inspected the durable child result and returned the exact marker without internal IDs
  • named bundle: /Applications/omi-main-qa.app (com.omi.omi-main-qa) against https://desktop-backend-dt5lrfkkoa-uc.a.run.app (development backend)

Product invariants affected

  • INV-AGENT-*
  • INV-AUTH-1
  • INV-CHAT-1
  • INV-VOICE-1

User-visible change

Push-to-talk retains shared context across repeated turns and provider failures, fails closed instead of sending audio with stale context, reports background-agent launch state from the same durable child lifecycle used by typed chat, and can reliably retrieve the final output of a just-completed OpenClaw child.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 92904c428c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 930 to +937
if !status.is_success() {
let body = upstream_resp.text().await.unwrap_or_default();
tracing::warn!(
"chat_completions: Anthropic returned {} for user {}: {}",
"chat_completions: Anthropic continuation returned {}: {}",
status,
user.uid,
&body[..body.len().min(500)]
);
return Ok(response_or_500(
Response::builder()
.status(StatusCode::from_u16(status.as_u16()).unwrap_or(StatusCode::BAD_GATEWAY))
.header("content-type", "application/json"),
Body::from(body),
));
return Err(StatusCode::BAD_GATEWAY);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve upstream errors for non-streaming requests

When any non-streaming completion gets an Anthropic non-2xx response (for example a BYOK 401 or a malformed-request 400), handle_non_streaming now reaches this helper and converts the provider status/body into a bare 502. The previous path returned the original status and JSON body, which callers need to distinguish credential/provider failures from gateway outages; this change will make invalid BYOK keys or request-shape errors look like transient backend failures instead of actionable upstream errors.

Useful? React with 👍 / 👎.

Comment on lines +149 to +152
const FRESH_PUBLIC_TEMPORAL_QUALIFIERS: &[&str] = &["right now", "currently", "today", "this week"];
const FRESH_PUBLIC_LOOKUP_TERMS: &[&str] = &[
"world cup",
"schedule",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Narrow freshness matches for scheduling requests

Because contains_any does raw substring matching and the temporal qualifiers include today/this week, adding schedule here makes ordinary action requests such as “schedule a call today” or “reschedule this week’s meeting” require public web search and prepend the required-web instruction before the model can handle the calendar/task intent. This policy is mirrored in agent/src/adapters/pi-mono.ts, so the schedule term should be constrained to public fixture/sports schedule wording or removed in both copies.

Useful? React with 👍 / 👎.

Share canonical context and lifecycle projections across typed chat and PTT, bound realtime tool results, and harden repeated-turn ownership.

Verified: 2390 Swift tests, 523 Node tests, 356 Rust tests, full agent-logic harness, cross-surface smoke, and named-bundle PTT burst.
Separate realtime transport readiness from context-bound input admission, persist failed/interrupted turns per continuity key, and require compact durable child lifecycle receipts for voice agent spawns.\n\nVerification:\n- desktop/macos/scripts/agent-logic-harness.sh --swift-only\n- desktop/macos/scripts/agent-logic-harness.sh --node-only\n- desktop/macos/agent npm run build\n- make preflight
Root cause: hubReady cancelled the warm deadline before context-bound input admission, and a rejected admission left released turns in finalizing + hubWarmWait until the idle socket teardown. Durable guard: add a typed hubAdmissionRejected reducer transition that restores the bounded transcription fallback and route the physical rejection through it. Regression coverage: VoiceTurnReducerTests.testHubAdmissionRejectionAfterTransportReadyFallsBackAfterRelease. Verification: focused Swift test, agent-logic-harness --swift-only, desktop test-quality, and make preflight all passed.
@Git-on-my-level
Git-on-my-level force-pushed the codex/qa-chat-regressions-main-20260713 branch from 9a5fe3e to 711b3a1 Compare July 14, 2026 02:11
@Git-on-my-level
Git-on-my-level merged commit fec07c1 into BasedHardware:main Jul 14, 2026
22 of 23 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.

1 participant