Skip to content

docs(sdk): document per-call prompt token composition metrics - #757

Open
georgeglarson wants to merge 6 commits into
OpenHands:mainfrom
georgeglarson:feat/llm-prompt-composition-metrics
Open

docs(sdk): document per-call prompt token composition metrics#757
georgeglarson wants to merge 6 commits into
OpenHands:mainfrom
georgeglarson:feat/llm-prompt-composition-metrics

Conversation

@georgeglarson

@georgeglarson georgeglarson commented Aug 24, 2026

Copy link
Copy Markdown
Contributor
  • I have read and reviewed the documentation changes to the best of my ability.
  • If the change is significant, I have run the documentation site locally and confirmed it renders as expected.

Summary of changes

Companion documentation for the prompt composition analysis tool (SDK PR OpenHands/software-agent-sdk#4623, reshaped from a runtime metric to an offline report script per review feedback).

  • New guide sdk/guides/llm-prompt-composition.mdx: documents enabling log_completions, running scripts/prompt_composition_report.py over a logs directory, reading the per-call buckets (system / tool_schema / history / latest) and the est/provider ratio, and the tool_schema_counted=false caveat for logs written before the SDK's logging-fidelity fix. No runtime API surface is documented because none exists.
  • sdk/guides/metrics.mdx: drops the prompt_compositions bullet (the runtime field no longer exists) and rewords the Next Steps link.
  • docs.json: registers the page under SDK → Guides → LLM Features (unchanged from the original PR).

Validation: mintlify broken-links reports no broken links; all CLI snippets checked against the script source.

georgeglarson and others added 3 commits August 25, 2026 02:31
Companion to the PromptComposition feature on
software-agent-sdk feat/llm-prompt-composition-metrics: per-call
decomposition of prompt tokens into system prompt, tool schemas,
conversation history, and latest message, recorded in LLM Metrics.

Co-authored-by: openhands <openhands@all-hands.dev>
Address review findings: join compositions to token usage by response_id
instead of positionally, qualify tool_tokens > 0 as native-FC agent steps
(mock-tools renders schemas into prompt text), note litellm's tool
serialization convention and fallback tokenizer, and document the
linear-in-prompt-size counting cost.

Co-authored-by: openhands <openhands@all-hands.dev>
Mirrors the SDK docstring caveat (OpenHands/software-agent-sdk#4623):
subscription mode folds the system prompt into the first user message,
so those tokens count as history/latest on that transport.

Co-authored-by: openhands <openhands@all-hands.dev>
@georgeglarson
georgeglarson force-pushed the feat/llm-prompt-composition-metrics branch from cafa8a3 to 3784e95 Compare August 25, 2026 06:32
Address rajshah4's review on software-agent-sdk#4623: composition
recording is now opt-in (default off), so the page leads with enabling
the flag and examples show it; the metrics field list notes the gate.

Co-authored-by: openhands <openhands@all-hands.dev>
@georgeglarson
georgeglarson marked this pull request as ready for review August 25, 2026 08:00
@georgeglarson
georgeglarson requested a review from enyst as a code owner August 25, 2026 08:00
georgeglarson and others added 2 commits August 25, 2026 21:53
The SDK PR was reshaped from a runtime opt-in metric to an offline
analysis script (scripts/prompt_composition_report.py) that ingests
LLM(log_completions=True) logs. Rework the guide to document enabling
completion logging, running the report (--root/--out/--no-chart), the
four buckets (tool_tokens is now tool_schema_tokens), the est/provider
median ratio, and the tool_schema_counted=false caveat for logs written
before tool schemas were logged in finalized form. Drop the
enable_prompt_composition flag, the metrics surface references, and the
runtime join example; note the report is the measurement baseline for
deferred tool loading (software-agent-sdk#4083). Remove the
prompt_compositions bullet from the metrics guide since the runtime
field no longer exists.

Co-authored-by: openhands <openhands@all-hands.dev>
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