mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
The system prompt lists tool snippets and per-tool guidelines in the order of the active tools. When an extension called `pi.setActiveTools()` with the same tools in a different order (for example `[...pi.getActiveTools()].reverse()`), the "tools" and "rules" sections came out different. pi then recorded a "System Prompt Update: tools, rules" message even though the active tools had not changed. On providers without mid-conversation system messages, this also rewrites the prompt head and loses the cache. `_applyToolLoadout` in `agent-session.ts` now treats the requested names as a set: - tools that stay active keep their current order; - newly activated tools are appended at the end. Reordering the same set therefore leaves the prompt unchanged. Adding a tool only appends its bullet. The same rule covers tool lists changed by `before_agent_start` handlers, since they go through the same function. Testing: - Added a test in `test/system-prompt-updates.test.ts`: it reverses the active tools between two prompts and expects a single system message. It fails without the change (a second message patches `tools` and `rules`) and passes with it. - `npm run check` passes. - `./test.sh`: all coding-agent suites pass. The only failure is an unrelated Anthropic model metadata test in `packages/ai`. Fixes #11495 Requested by @badlogic Co-authored-by: triagent <triagent@localhost> |
||
|---|---|---|
| .. | ||
| bun | ||
| cli | ||
| core | ||
| experimental | ||
| extensions | ||
| modes | ||
| utils | ||
| cli.ts | ||
| config.ts | ||
| index.ts | ||
| main.ts | ||
| migrations.ts | ||
| package-manager-cli.ts | ||
| rpc-entry.ts | ||