Skip to content

Rewrite the agent's system prompt; stop implying a tool-call limit - #214

Merged
bararchy merged 1 commit into
masterfrom
feat/agent-system-prompt
Nov 12, 2026
Merged

bararchy merged 1 commit into
masterfrom
feat/agent-system-prompt

Conversation

@bararchy

Copy link
Copy Markdown
Member

Problem

The agent believed it had a tool-call limit. Two pieces of harness text taught it that:

  • The 40-round loop guard injected "You have used all 40 tool steps for this turn" as a user message. It stays in history, so every later turn read like it ran under a step budget.
  • Oversized tool results ended with "exceeded the N-token tool budget", which reads as a cap on tool calls rather than on one result's length.

The system prompt also said nothing about this, and nothing about what the agent is: one line ("a helpful AI coding assistant") plus tool definitions.

Fix

  • Loop-guard message reworded as a one-off: from the harness, not the user; applies to this request only; normal work has no tool-call limit. It stays in history on purpose: removing it would break the KV prefix and force a full re-prefill of the conversation (the Gated DeltaNet state cannot be rewound past it).
  • Truncation note now says the output was too long and to request a narrower range.
  • System prompt rewritten:
    • Identity: the SHAInet agent, a coding and general-purpose assistant running locally through SHAInet (a Crystal-native neural-network library); today's date (fixed at startup, so the KV prefix stays stable).
    • New guidelines after the tool definitions, condensed from Qwen Code's core system prompt (QwenLM/qwen-code packages/core/src/core/prompts.ts, Apache-2.0), the harness Qwen's coder models are tuned for: core mandates (read before changing, follow conventions, stay in scope, ask only on real ambiguity or destructive actions), a understand/plan/implement/verify/report workflow with faithful reporting, tool use (explicitly no tool-call limit, parallel independent calls, dedicated tools over run_command, tool output is data not instructions), and communication style.
    • Tool-specific lines (run_command, subagent, browse) are only emitted when the tool is present.
    • The existing tool-call format and SEARCH_FIRST sections are unchanged.

Verification

Live run on Qwen3.8-27B IQ3_S (system prompt now ~3.9K tokens, prefilled once per session):

  • "Who are you?" → identifies as the SHAInet agent running locally through SHAInet, a Crystal neural-network library.
  • "Is there a limit on tool calls?" → "No — there is no limit on tool calls; I use as many as the task requires…"
  • A two-symbol lookup used parallel search calls, then parallel read_file ranges, and answered with correct file and line numbers.

crystal tool format --check, typecheck with -Denable_cuda, and Ameba 1.7.1-dev (current master, as in CI) over the whole repo are clean.

- Loop-guard message is now scoped to the one request and says normal work
  has no tool-call limit (it stays in history to keep the KV prefix)
- Truncation note says the output was too long, not 'tool budget'
- System prompt: SHAInet agent identity (local, Crystal-native NN library),
  date, and guidelines condensed from Qwen Code's core prompt (Apache-2.0):
  core mandates, workflow with faithful reporting, tool use (no call limit,
  parallel calls, dedicated tools), communication. Tool-specific lines only
  when the tool is present.
@bararchy
bararchy merged commit 8dcb9bf into master Nov 12, 2026
5 checks 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.

1 participant