docs(sdk): document per-call prompt token composition metrics - #757
Open
georgeglarson wants to merge 6 commits into
Open
docs(sdk): document per-call prompt token composition metrics#757georgeglarson wants to merge 6 commits into
georgeglarson wants to merge 6 commits into
Conversation
1 task
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
force-pushed
the
feat/llm-prompt-composition-metrics
branch
from
August 25, 2026 06:32
cafa8a3 to
3784e95
Compare
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
marked this pull request as ready for review
August 25, 2026 08:00
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).
sdk/guides/llm-prompt-composition.mdx: documents enablinglog_completions, runningscripts/prompt_composition_report.pyover a logs directory, reading the per-call buckets (system / tool_schema / history / latest) and the est/provider ratio, and thetool_schema_counted=falsecaveat for logs written before the SDK's logging-fidelity fix. No runtime API surface is documented because none exists.sdk/guides/metrics.mdx: drops theprompt_compositionsbullet (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-linksreports no broken links; all CLI snippets checked against the script source.