Skip to content

Improvement/prompt audit - #514

Merged
CraftOS-dev merged 16 commits into
V1.4.5from
improvement/prompt-audit
Nov 3, 2026
Merged

CraftOS-dev merged 16 commits into
V1.4.5from
improvement/prompt-audit

Conversation

@CraftOS-dev

Copy link
Copy Markdown
Owner

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.

CraftBot and others added 3 commits October 30, 2026 17:26
…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>
@CraftOS-dev
CraftOS-dev marked this pull request as ready for review November 2, 2026 06:58
…tinuati9on

fix: preserve tool results and trim duplicate prompt context
@CraftOS-dev
CraftOS-dev merged commit e7d2b57 into V1.4.5 Nov 3, 2026
1 check passed
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.

3 participants