Skip to content

fix(sight): show non-streaming LLM calls in audit#681

Merged
chengshuyi merged 1 commit into
alibaba:mainfrom
jfeng18:fix/sight-per-call-token
Jun 25, 2026
Merged

fix(sight): show non-streaming LLM calls in audit#681
chengshuyi merged 1 commit into
alibaba:mainfrom
jfeng18:fix/sight-per-call-token

Conversation

@jfeng18

@jfeng18 jfeng18 commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

Make non-streaming LLM calls visible in audit --type llm. Previously analyze_http returned None for non-SSE requests, so non-streaming completions (stream: false) never produced an audit record.

What changed

File Change
analyzer/audit/analyzer.rs analyze_http also emits an llm_call for non-streaming LLM API calls (matched by path: /chat/completions, /v1/messages, /v1/completions, /api/v1/copilot/generate_copilot); is_sse now reflects the record instead of being hardcoded true; +3 unit tests

Scope (narrowed)

This PR was narrowed to analyzer/audit/analyzer.rs only. The earlier version also touched analyzer/unified.rs to extract non-streaming token usage, which overlaps #789 (the comprehensive non-streaming + H2 token extraction). That part was dropped so the two PRs do not conflict:

Merge order: #789 first. Until it lands, non-streaming calls appear in audit with 0 tokens; they get real counts once #789 is merged.

Verification (ECS, rustc 1.89 = CI toolchain)

  • cargo build --release, cargo fmt --all --check, cargo clippy --all-targets -- -D warnings: PASS
  • Tests pass, including 3 new discriminating unit tests
  • diff-cover vs origin/main: 95%

Note: issue link TBD — previously referenced #782, which is unrelated (that is the config-watcher process::exit bug, fixed by #783).

@jfeng18

jfeng18 commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator Author

Gentle ping — this fixes #699 (per-call token always null in audit records). 3 discriminating unit tests + ECS E2E verified. Ready for review.

@jfeng18 jfeng18 force-pushed the fix/sight-per-call-token branch 2 times, most recently from 9c2caf8 to 3558624 Compare June 6, 2026 13:22
@jfeng18

jfeng18 commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator Author

Per-call token audit (123 lines). Adds per-invocation token tracking to the audit path.

@jfeng18 jfeng18 force-pushed the fix/sight-per-call-token branch 2 times, most recently from e79ff6e to 7bd8552 Compare June 16, 2026 23:33
@jfeng18 jfeng18 changed the title fix(sight): per-call token in audit records fix(sight): show non-streaming LLM calls in audit Jun 16, 2026
@jfeng18 jfeng18 force-pushed the fix/sight-per-call-token branch from 7bd8552 to cae6cdb Compare June 25, 2026 08:10
audit --type llm only showed SSE (streaming) calls: analyze_http
returned None for non-SSE requests, so non-streaming completions
(stream:false) were invisible.

Create an llm_call audit record for non-streaming LLM API calls too
(matched by path: /chat/completions, /v1/messages, /v1/completions,
/api/v1/copilot/generate_copilot), and set is_sse from the record
instead of hardcoding true.

Non-streaming token extraction is handled separately by alibaba#789; merge
that first so these records carry token counts.
@jfeng18 jfeng18 force-pushed the fix/sight-per-call-token branch from cae6cdb to baf9f7f Compare June 25, 2026 08:20
@chengshuyi chengshuyi merged commit 8fb41e4 into alibaba:main Jun 25, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component:sight src/agentsight/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants