Repository navigation
fix(macos): harden shared chat and PTT agent continuity - #9660
Git-on-my-level merged 8 commits into
Conversation
There was a problem hiding this comment.
💡 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".
| 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); |
There was a problem hiding this comment.
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 👍 / 👎.
| const FRESH_PUBLIC_TEMPORAL_QUALIFIERS: &[&str] = &["right now", "currently", "today", "this week"]; | ||
| const FRESH_PUBLIC_LOOKUP_TERMS: &[&str] = &[ | ||
| "world cup", | ||
| "schedule", |
There was a problem hiding this comment.
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.
9a5fe3e to
711b3a1
Compare
Summary
background_agent/delegated_agentdiscovery resolve durable leaf sessions across concrete UI surfaces, with bounded result payloadsRoot cause and durable guard
Oracle review identified one split-authority failure class rather than model forgetfulness. A connected socket was treated as context-ready,
hubDidConnectcould 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_agentsurfaces, while child runs are persisted under concrete surfaces such asfloating_bar. Exact filtering returned no child; merely removing the filter let a newer coordinator winlimit: 1. The runtime now maps those semantic hints toexecutionRole = 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 proveslimit: 1still returns the leaf result.Verification
make setup— refreshedorigin/mainand installed linked-worktree-safe hooksgit diff --check— passedcd desktop/macos && ./scripts/agent-logic-harness.sh --swift-only— focused voice lifecycle, context admission, persistence race, and spawn-contract suites passedcd desktop/macos && ./scripts/agent-logic-harness.sh --node-only— agent runtime and pi-mono extension suites passedcd desktop/macos/agent && npm test -- control-tools.test.ts omi-tool-manifest.test.ts— 95 tests passedcd 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 passedOPENCLAW-HANDOFF-FINAL; the immediate next PTT turn inspected the durable child result and returned the exact marker without internal IDs/Applications/omi-main-qa.app(com.omi.omi-main-qa) againsthttps://desktop-backend-dt5lrfkkoa-uc.a.run.app(development backend)Product invariants affected
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.