Repository navigation
Improvement/prompt audit - #514
Merged
Merged
Conversation
…tem prompt T0: prompt audit tooling - scripts/prompt_profile.py: --sections (tokens per prompt block), --cache (cache use per model, full prompts vs deltas, delta misses), --duplication (decision inputs sent again in the next delta). - scripts/prompt_replay.py: replays captured decision calls in the captured and a candidate layout and compares the chosen actions against the model's own run-to-run agreement. Decision calls only, no action is executed, nothing is written to llm_calls.db or usage.db. T1: the decision instructions end the system prompt - SELECT_ACTION_PROMPT is split into SELECT_ACTION_INSTRUCTIONS (rules, output format, <actions>) and the session's own part. The instructions end the system prompt (decision_system_prompt), so every session of a type reads them from the provider's cache from its first call. The model reads the same text in the same order; only the message boundary moved. - A session history keeps the instructions it started with until it starts anew, so a change in what renders now (the Mini Browser rule dropping after a failed launch) never breaks a cached prefix in progress. - One builder, ContextEngine.make_decision_system_prompt (fed by the router's decision_instructions hook), for the decision call, /fold and both session cache registrations. No other LLM call is affected. - Saved session histories carry a format number; a history saved before this change is not restored (the session starts a new prefix once). - The Mini Browser prompt filter now applies to the instructions only, never to the event stream. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
added 9 commits
October 30, 2026 21:11
CraftOS-dev
marked this pull request as ready for review
November 2, 2026 06:58
Signed-off-by: ahmad-ajmal <ahmadajmal1514@gmail.com>
This was referenced Nov 2, 2026
…tinuati9on fix: preserve tool results and trim duplicate prompt context
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.
What and why?
The context of first agent request reached 21k tokens and is piling up. This PR perform a prompt audit and optimize the token usage of CraftBot.