mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-11 05:42:22 +00:00
fix(voice): log a real send before bookkeeping; document decision reasons
Second review pass on #835's diagnostics. Behaviour is unchanged. - Report viewport_context.result as soon as the send returns, so a throw in the retained-frame bookkeeping cannot log a real send as "error". - List the decision reasons and when each field is present in CURRENT-STATE, note that the rate limit can split a pair, and say which codes are defensive. - Changelog: the decision is logged when an entity-context answer reaches the image step, not for every answer.
This commit is contained in:
1 parent
207eb9805d
commit
d0a612786a
4 files changed
+34
-11
No files matched your search
@@ -1,7 +1,7 @@
|
||||
- The voice debug log now says why OpenAI Realtime did or did not get a
|
||||
viewport screenshot or pointer crop. Each entity-context answer logs a
|
||||
reason-coded decision and, when an image was due, one outcome under the same
|
||||
id, so a crop that was dropped because the pointer went stale or the camera
|
||||
moved is no longer counted as sent. What is captured, sent and kept is
|
||||
unchanged, and no image data or user text is logged (kvnloo, manjunath22466,
|
||||
#835).
|
||||
viewport screenshot or pointer crop. When an entity-context answer reaches
|
||||
the image step, the log records a reason-coded decision and, when an image
|
||||
was due, one outcome under the same id, so a crop that was dropped because
|
||||
the pointer went stale or the camera moved is no longer counted as sent.
|
||||
What is captured, sent and kept is unchanged, and no image data or user text
|
||||
is logged (kvnloo, manjunath22466, #835).
|
||||
@@ -5779,7 +5779,7 @@ and unreachable upstream (502/504) separately from road geometry.
|
||||
- **Reliability**: tool-call dedupe (2.5s window across call/item/args keys); response-create queueing that respects active responses and defers follow-ups when the user starts speaking; per-tool follow-up instructions so the agent confirms only what actually happened (zoom confirms only on `ok=true`).
|
||||
- **Aircraft identity honesty:** “What is this aircraft?” reads callsign, operator, registration, type, and route only from the selected contact context. Missing operator, route, or type enrichment is named explicitly rather than silently omitted or inferred from the callsign.
|
||||
- **Diagnostics**: every client/server event is posted to `/api/realtime/debug-log` and appended to `.gev-logs/realtime-conversations.jsonl` (gitignored) with secret/image redaction; last 30 errors persist in `localStorage` (`gev-realtime-errors`); `window.__gevVoiceCommands.getDiagnostics()` in the console.
|
||||
- **Visual-context escalation** (OpenAI Realtime): when a `get_entity_context` answer reaches the image step (its tool output was sent and the data channel is open), it logs one `viewport_context.decision` (`contextId`, `send`, `kind` `viewport` or `crop`, `reason`, `viewScale`). A send decision is followed by exactly one outcome with the same `contextId` and `kind`: `viewport_context.result` (`sent`, `data-channel-send-failed`) or `viewport_context.skipped`. Pointer-crop skips are `pointer-not-fresh`, `pointer-not-ground`, `pointer-off-screen`, `pointer-already-requested` (the same snapshot was already sent or is still being captured), `pointer-expired`, `pointer-pose-unknown` and `pose-changed`; dropped captures are `capture-unavailable`, `session-reset`, `superseded` (a newer request or turn), `channel-lost` and `frame-stale`; a step that throws closes the pair with `error` before the caller logs `viewport_context.failed`. `channel-closed` and the crop's `pointer-scale-not-useful` are defensive and not expected from the current caller. Payloads are static codes only, never image data, tool payloads or user text, and other tool results log nothing here. Gemini Live uses a different gate in `geminiSession.js` (no pointer crop, a 1 s throttle), which is not instrumented.
|
||||
- **Visual-context escalation** (OpenAI Realtime): when a response's last tool result is a `get_entity_context` answer and its tool output was sent with the data channel open, it logs one `viewport_context.decision` with `contextId`, `send` and `reason`, plus `viewScale` (absent only for `channel-closed`) and, when `send` is true, `kind` (`viewport` or `crop`). Decision reasons: `structured-identity-sufficient` (structured context made an image unnecessary), `view-scale-not-local`, `structured-identity-missing` (sends a viewport), `pointer-ground-crop` (sends a crop), `pointer-identity-present`, `pointer-missing`, `pointer-scale-not-useful` and `channel-closed`. A send decision is followed by exactly one outcome with the same `contextId` and `kind`: `viewport_context.result` (`sent`, `data-channel-send-failed`), logged as soon as the send returns, or `viewport_context.skipped`. Pointer-crop skips are `pointer-not-fresh`, `pointer-not-ground`, `pointer-off-screen`, `pointer-already-requested` (the same snapshot was already sent, is still being captured, or an earlier capture of it failed), `pointer-expired`, `pointer-pose-unknown` and `pose-changed`; dropped captures are `capture-unavailable`, `session-reset`, `superseded` (a newer request or turn), `channel-lost` and `frame-stale`; a step that throws before an outcome closes the pair with `error`, and the caller then logs `viewport_context.failed`. The `channel-closed` decision and the `channel-closed` and `pointer-scale-not-useful` skip outcomes are defensive and not expected from the current caller. Decision and outcome are separate records, so the debug-log rate limit can drop one half of a pair. Payloads are static codes only, never image data, tool payloads or user text, and other tool results log nothing here. Gemini Live uses a different gate in `geminiSession.js` (no pointer crop, a 1 s throttle), which is not instrumented.
|
||||
- **Counting semantics ("near")** — a CONTRACT; new count-bearing tool work inherits it. Three honest numbers exist for one question: the Contacts cohort (250 km around the subject, what the panel shows), `analyst_query`'s count of _currently-loaded_ records for the requested scope, and the layer-wide loaded total in `coverage.layersQueried[].total`. They diverge legitimately — the flights layer loads by viewport, so after a camera dive the loaded set can hold a fraction of the cohort (field case: panel 42, analyst 8). The contract:
|
||||
1. **Contacts ACTIVE** → "near / nearby / how many aircraft" means the **Contacts window** — the panel's numbers, spoken verbatim. Mechanism: `contactsWindow` (`{centeredOn, radiusKm, flights, military, vessels, complete}`), carried by both `analyst_query` and `get_current_view_state`, derived by `contactsWindowFromSnapshot()` from the same snapshot the panel renders so the two cannot drift. Voice filtering and follow-up memory use that immutable snapshot too. A cohort whose feed cannot answer reports `'unknown'`, never a confident zero; a cohort at the 20,000-row retention bound reports a lower bound.
|
||||
2. **Contacts OFF** → "nearby" means **in view**; "near \<place\>" means a radius around that place. A radius query with Contacts active and no explicit centre is centred on the **active contact**, not the camera.
|
||||
|
||||
@@ -562,6 +562,12 @@ export class RealtimeViewport {
|
||||
// the item we just deleted as null and fall through so the caller still
|
||||
// issues queueResponseCreate WITHOUT the image, instead of stranding the turn.
|
||||
const sent = this.sendRealtimeEvent(contextEvent, label);
|
||||
// Report before the bookkeeping below, so a later throw cannot turn a
|
||||
// real send into a logged "error".
|
||||
report(
|
||||
'viewport_context.result',
|
||||
sent ? 'sent' : 'data-channel-send-failed',
|
||||
);
|
||||
this.lastViewportItemId = sent ? newItemId : null;
|
||||
this.retainedFrame = sent
|
||||
? {
|
||||
@@ -570,10 +576,6 @@ export class RealtimeViewport {
|
||||
cameraKey: this.readCameraKey(),
|
||||
}
|
||||
: null;
|
||||
report(
|
||||
'viewport_context.result',
|
||||
sent ? 'sent' : 'data-channel-send-failed',
|
||||
);
|
||||
return sent;
|
||||
}
|
||||
|
||||
|
||||
@@ -536,3 +536,24 @@ test('a step that throws still closes its decision, then rethrows', async () =>
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
test('a throw after a real send still logs it as sent', async () => {
|
||||
let reads = 0;
|
||||
const { viewport, events } = recordingViewport({
|
||||
// The first read happens only after the image was handed to the channel.
|
||||
readCameraKey: () => {
|
||||
reads += 1;
|
||||
throw new Error('camera gone');
|
||||
},
|
||||
});
|
||||
await assert.rejects(
|
||||
viewport.sendVisualContextIfUseful(localContext()),
|
||||
/camera gone/,
|
||||
);
|
||||
assert.equal(reads, 1);
|
||||
const outcomes = events.filter((item) => outcomeEvents.has(item.event));
|
||||
assert.deepEqual(
|
||||
outcomes.map((item) => [item.event, item.detail.reason]),
|
||||
[['viewport_context.result', 'sent']],
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user