Strip XML tags, runtime model metadata, run detail UI#90
Open
Conversation
Add response_sanitizer module that strips internal reasoning tags (thinking, reflection, scratchpad, etc.), special control tokens (eot_id, im_end, etc.), and recovers structured tool calls from XML blocks in LLM output. Integrated at both the agent runner level and the gateway streaming path.
Add ModelMetadata struct and model_metadata() trait method to LlmProvider with a default implementation that returns the static context_window() value. Override in OpenAiProvider to fetch context length from the /models API endpoint with OnceCell caching. Use runtime metadata for auto-compaction threshold in the gateway.
Add sessions.run_detail RPC method that returns messages for a specific run_id, plus a RunDetail Preact component with Overview, Actions, and Messages tabs. The component is mounted on assistant messages that have a run_id. Tool results now carry run_id for linking. Includes backend tests and E2E specs.
Apply rustfmt, biome, and clippy fixes across the three feature commits. Add changelog entries for XML tag stripping, runtime model metadata, and run detail UI features.
Contributor
Merging this PR will improve performance by ×2.6
Performance Changes
Comparing Footnotes
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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
response_sanitizermodule strips internal XML tags (thinking, reasoning, scratchpad, etc.), pipe tokens (<|eot_id|>,<|im_end|>, etc.), and reasoning pattern blocks from LLM responses. Also recovers structured tool calls from XML blocks as a fallback. Integrated in both streaming and non-streaming paths in the agent runner and gateway chat handler.ModelMetadatastruct andmodel_metadata()trait method onLlmProviderwith a default implementation. OpenAI provider overrides it to fetch context window from/models/{model}API withOnceCellcaching and static fallback on error. Auto-compaction now uses runtime metadata for accurate context window sizing.read_by_run_idstore method,sessions.run_detailRPC endpoint, and a PreactRunDetailcomponent with Overview/Actions/Messages tabs. Expandable button appears on assistant messages that have arun_id. Tool results now propagaterun_idfor proper grouping.Validation
Completed
just format-checkpassescargo clippy -p moltis-agents -p moltis-sessions -p moltis-gateway -- -D warningscleancargo test— all tests pass (including 20 new sanitizer tests, 5 new metadata tests, 2 new store tests)biome check --writeapplied to JS filesRemaining
./scripts/local-validate.sh <PR>— to be run after PR creationcd crates/gateway/ui && npx playwright testManual QA
Pending — will be performed after local validation completes.