Skip to content

fix(server): retain delegated cache counts from protocol usage - #254

Closed
Afloat16 wants to merge 1 commit into
Edge0-AI:mainfrom
Afloat16:fix/messages-cache-counts-20261116
Closed

Afloat16 wants to merge 1 commit into
Edge0-AI:mainfrom
Afloat16:fix/messages-cache-counts-20261116

Conversation

@Afloat16

@Afloat16 Afloat16 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

What & why

Delegated Messages and Responses requests can report cache hits through their protocol usage objects without a timings object. The proxy currently leaves reused_tokens null for those requests, so /status, the last request and aggregate totals lose reported cache reuse.

Read Messages usage.cache_read_input_tokens from both the initial message and final delta, and Responses usage.input_tokens_details.cached_tokens. Preserve an explicitly reported zero and the existing timing-count precedence. Forwarded HTTP bodies and SSE bytes stay unchanged.

Area

  • Engine, CLI or server (edge0-infer/)

How was it tested?

The isolated before/after validation starts from upstream f6bfa5546bcf89919f86946ec669bcc7f4cd526d and tests the exact source and regressions in this PR.

  • Before: the native Messages reuse assertion fails; real HTTP requests through the native proxy also reproduce missing cache counts. A separate Responses control remained red with only the Messages correction applied.
  • After on Linux: native accounting regressions pass, including one-byte SSE chunks, zero counts, malformed optional fields and timing precedence. Full L0/L1: 98 passed, 3 device skips and 3 reproduced upstream failures (platform_memory, ordered_json, template_tools). Full ctest --preset cpu --no-tests=error --output-on-failure -L L2 -R strata: 2 passed.
  • The HTTP regressions exercise both streaming and ordinary Messages/Responses, check byte-exact forwarding and verify per-request and aggregate counts. They use the repository's fake engine with the real native proxy, without a model or GPU claim.
  • Local Linux native and HTTP checks also passed. The local combined worktree's full L0/L1 retains the existing app_generation temporary-file and platform_memory environment failures; the production dependency-manifest check passes.

macOS validation completed. The repository's official macOS CI passed: all 101 runnable L0/L1 tests passed, 3 device tests were skipped, and both delegated-engine L2 tests passed. The earlier fork macOS job had not obtained a runner; the official run now supplies that platform result.

Checklist

  • Full local L0/L1 passes: the reproduced environment/baseline failures are listed above.
  • Ran the affected native and HTTP integration tests.
  • Added regression tests for the changed behavior.
  • Updated the relevant server documentation.

@Afloat16

Copy link
Copy Markdown
Contributor Author

Superseded by #291, the consolidated delegated-serving PR requested in #289. The original change and regression coverage are preserved, and the original commit remains in the consolidated branch's history.

@Afloat16 Afloat16 closed this Nov 17, 2026
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