Skip to content

[Improve] Require explicit LLM usage source attribution - #1573

Draft
roomote-roomote[bot] wants to merge 2 commits into
developfrom
feature/llm-usage-source-attribution-2o4sgptihd864
Draft

[Improve] Require explicit LLM usage source attribution#1573
roomote-roomote[bot] wants to merge 2 commits into
developfrom
feature/llm-usage-source-attribution-2o4sgptihd864

Conversation

@roomote-roomote

@roomote-roomote roomote-roomote Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

​Opened on behalf of @mrubens. Follow up by mentioning @roomote-roomote or in the web UI.

What changed

  • Audited every tracked llmUsage.record entry point, including the SDK wrapper, worker SDK usage, harness code, and generated sandbox plugin scripts.
  • Made source required by the in-repo sdk.llmUsage.record() helper so future callers must identify their usage surface.
  • Reject blank and whitespace-only source values at the tRPC boundary, and trim meaningful source values before recording them.
  • Kept the tRPC input optional and preserved input.source ?? 'opencode' for backward compatibility with deployed clients that omit the field.
  • Added contract and router tests covering required attribution, blank-value rejection, and normalization.

The audit found no current in-repo caller of llmUsage.record, so there were no existing missing callers to assign new source strings. Active recording paths already attribute usage explicitly: task inference uses opencode, the inference gateway uses inference-gateway, and non-task inference uses semantic values from NON_TASK_INFERENCE_SURFACES.

Why this change was made

The endpoint fallback can silently collapse newly added SDK callers into the generic opencode bucket, while explicit blank strings can create a separate unattributed bucket. Requiring attribution in the SDK and validating explicit values at the RPC boundary prevents both cases without breaking older deployed clients that still need the server fallback.

Impact

New TypeScript callers of the SDK helper must provide a source. Explicit blank sources are rejected, padded sources are normalized, and direct or older tRPC clients that omit source remain compatible.

@roomote-community

roomote-community Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

No new code issues found. See task

  • Reject blank and whitespace LLM usage sources (packages/sdk/src/llm-usage.ts:7).

Reviewed 26cc524

Comment thread packages/sdk/src/llm-usage.ts
@roomote-roomote

roomote-roomote Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

Fixed blank and whitespace LLM usage source handling in 26cc524a. The RPC now rejects blank values, trims meaningful values, and retains omission compatibility.

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