Repository navigation
"classify-memories" task uses my system prompt #232
Description
Short description
"classify-memories" task is not using its own system prompt in pi
What happened?
Harness is pi. I monitored system prompts while the dreamer was running and noticed that:
"You are a memory mapper for the magic-context system." as system prompt + "## Map these memories to their backing files" as first user message works - good
"You are a memory verifier for the magic-context system. " + "## Verify these memories against the code" - also good
"You are a memory-pool curator for the magic-context system" + "## Task: Curate Project Memory Pool" - good
and at the end
"my prompt" + ## Task: Classify Project Memories"
That means the classify-memories task didn't use its prompt, but used my own. What's worse, it's not the default prompt it should have access to; it comes from an extension and only when specifically enabled (it's not on by default). To rule out my extension somehow altering the dreamer's prompt, I ran pi only with magic-context with pi -ne --extension "npm:@cortexkit/pi-magic-context@0.32.3" and then /ctx-dream classify-memories, but it still used that prompt that comes from this very specific extension, and only when explicitly enabled. That means magic-context stored this prompt somewhere and is using it.
You are a coding assistant operating inside pi, a coding agent harness. You help users by reading files and looking up missing information on the internet. You are in read-only **Ask** mode: do not modify local files, repositories, or external systems.
That is not a standard pi system prompt; it comes from this:
It is my subagent system.
Diagnostics
## Environment
- Pi plugin: v0.32.3
- Pi: 0.80.10
- OS: linux x64
- Node: v24.18.0
## Diagnostics
- Timestamp: 2026-07-19T05:22:22.349Z
- Pi plugin: v0.32.3
- OS: linux x64
- Node: v24.18.0
- Pi installed: true (0.80.10)
- Magic Context package registered: true
- User config parse error: none
- Project config parse error: none
- Known Pi extension conflicts: none
### Pi settings
{
"path": "<HOME>/.pi/agent/settings.json",
"exists": true,
"hasMagicContextPackage": true,
"packages": [
"npm:@cortexkit/aft-pi@0.47.1",
"npm:@cortexkit/pi-magic-context@0.32.3"
]
}
### Config paths
{
"agentDir": "<HOME>/.pi/agent",
"userConfig": "<HOME>/.config/cortexkit/magic-context.jsonc",
"projectConfig": "/home/<USER:545ea5384610>/Praca/.pi/.cortexkit/magic-context.jsonc"
}
### User magic-context.jsonc flags
{
"$schema": "https://raw.githubusercontent.com/cortexkit/magic-context/master/assets/magic-context.schema.json",
"cache_ttl": {
"default": "10m"
},
"execute_threshold_percentage": {
"default": 65,
"minimax/minimax-m3": 60,
"openai-codex/gpt-5.5": 75,
"openai-codex/gpt-5.6-sol": 65,
"openai-codex/gpt-5.6-terra": 65,
"openai-codex/gpt-5.6-luna": 65
},
"language": "en",
"auto_update": false,
"memory": {
"git_commit_indexing": {
"enabled": true
}
},
"historian": {
"model": "omniroute/quick_free",
"fallback_models": [
"minimax/minimax-m3"
]
},
"dreamer": {
"model": "omniroute/quick_free",
"fallback_models": [
"minimax/minimax-m3"
],
"tasks": {
"map-memories": {
"schedule": "0 16 * * *"
},
"verify": {
"schedule": "0 17 * * *"
},
"verify-broad": {
"schedule": "0 18 * * 0"
},
"curate": {
"schedule": "0 18 * * 0"
},
"classify-memories": {
"schedule": "0 20 * * *"
},
"retrospective": {
"schedule": "0 19 * * *"
},
"maintain-docs": {
"schedule": ""
},
"promote-primers": {
"schedule": "0 17 * * *",
"promotion_threshold": 2
},
"refresh-primers": {
"schedule": "0 17 * * *"
},
"evaluate-smart-notes": {
"schedule": "0 17 * * *"
},
"review-user-memories": {
"schedule": "0 17 * * *",
"promotion_threshold": 3
}
}
},
"sidekick": {
"enabled": true,
"model": "omniroute/quick_free",
"fallback_models": [
"minimax/minimax-m3"
],
"timeout_ms": 30000
}
}
### Project magic-context.jsonc flags
{}
### Loaded config paths
- <HOME>/.config/cortexkit/magic-context.jsonc
### Config load warnings
_None._
### Shared storage
{
"path": "<HOME>/.local/share/cortexkit/magic-context",
"exists": true,
"context_db_size": "18.4 MB"
}
### Pi extension conflicts
No known conflicting Pi extensions are currently registered. Other Pi packages are informational only.
{
"knownConflicts": [],
"otherPiExtensions": [
"npm:@cortexkit/aft-pi@0.47.1"
]
}
### Log file
- Path: /tmp/pi/magic-context/magic-context.log
- Exists: true
- Size: 5 KB
## Recent errors (last 20, sanitized)
[2026-07-19T05:21:56.270Z] [dreamer] classify chunk failed: Error message="classify manifest missing id 65" {"stackHead":"Error: classify manifest missing id 65 | at assertManifestCoversExactly (<HOME>/.pi/agent/tmp/extensions/npm/f35b2129/<USER:545ea5384610>_modules/@cortexkit/pi-magic-context/dist/index.js:198863:1061) | at applyClassifications (<HOME>/.pi/agent/tmp/extensions/npm/f35b2129/<USER:545ea5384610>_modules/@cortexkit/pi-magic-context/dist/index.js:198912:5103) | at classifyOneChunk (<HOME>/.pi/agent/tmp/extensions/npm/f35b2129/<USER:545ea5384610>_modules/@cortexkit/pi-magic-context/dist/index.js:198912:4321)"}Plugin version
No response
OpenCode version
No response
Platform
No response
Client
Pi
Log output (optional)
## Log (last 400 lines, sanitized)
[2026-07-19T05:20:14.982Z] [migrations] migration lock check attempt 1/6
[2026-07-19T05:20:15.000Z] [magic-context][pi] rehydrated 6 Pi deferred compaction marker session(s)
[2026-07-19T05:20:15.000Z] [magic-context][pi] loaded v0.32.3 | harness=pi | db=<HOME>/.local/share/cortexkit/magic-context/context.db | project=git:dfe1725c3993d78dea18147fcfe472cf815a457d | dir=/home/<USER:545ea5384610>/Praca/.pi
[2026-07-19T05:20:15.010Z] [magic-context][pi] config loaded from: <HOME>/.config/cortexkit/magic-context.jsonc
[2026-07-19T05:20:15.022Z] [magic-context][pi] registered embedding config for project git:dfe1725c3993d78dea18147fcfe472cf815a457d
[2026-07-19T05:20:15.022Z] [magic-context][pi] registered tools: ctx_search, ctx_memory, ctx_note, ctx_expand, todowrite, ctx_reduce; registered /todos
[2026-07-19T05:20:15.023Z] [magic-context][pi] registered todowrite overlay
[2026-07-19T05:20:15.023Z] [magic-context][pi] registered context handler (tagging + drops + nudges)
[2026-07-19T05:20:15.023Z] [magic-context][pi] registered historian trigger (model=omniroute/quick_free, executeThreshold=65% (minimax/minimax-m3=60%, openai-codex/gpt-5.5=75%, openai-codex/gpt-5.6-sol=65%, openai-codex/gpt-5.6-terra=65%, openai-codex/gpt-5.6-luna=65%))
[2026-07-19T05:20:15.023Z] [magic-context][pi] registered auto-search hint (threshold=0.6, minChars=20)
[2026-07-19T05:20:15.023Z] [magic-context][pi] registered /ctx-aug (sidekick model=omniroute/quick_free)
[2026-07-19T05:20:15.023Z] [magic-context][pi] registered model-invisible ctx-status entry renderer
[2026-07-19T05:20:15.023Z] [magic-context][pi] registered /ctx-status
[2026-07-19T05:20:15.023Z] [magic-context][pi] registered magic-context status line
[2026-07-19T05:20:15.023Z] [magic-context][pi] registered /ctx-flush
[2026-07-19T05:20:15.024Z] [magic-context][pi] registered /ctx-recomp
[2026-07-19T05:20:15.024Z] [magic-context][pi] registered /ctx-wrapup
[2026-07-19T05:20:15.024Z] [magic-context][pi] registered /ctx-session-upgrade
[2026-07-19T05:20:15.024Z] [magic-context][pi] registered /ctx-dream
[2026-07-19T05:20:15.024Z] [magic-context][pi] registered /ctx-embed
[2026-07-19T05:20:15.025Z] [dreamer] registered project git:dfe1725c3993d78dea18147fcfe472cf815a457d (dreaming=true embeddings=false commits=true; total=1)
[2026-07-19T05:20:15.025Z] [dreamer] started independent schedule timer (every 15m)
[2026-07-19T05:20:15.025Z] [magic-context][pi] registered dreamer (map-memories 0 16 * * *, verify 0 17 * * *, verify-broad 0 18 * * 0, curate 0 18 * * 0, classify-memories 0 20 * * *, retrospective 0 19 * * *, evaluate-smart-notes 0 17 * * *, review-user-memories 0 17 * * *, promote-primers 0 17 * * *, refresh-primers 0 17 * * *)
[2026-07-19T05:20:15.025Z] [magic-context][pi] registered before_agent_start system prompt injector
[2026-07-19T05:21:44.756Z] [magic-context][pi-status] /ctx-dream: ## /ctx-dream
Running dream task "classify-memories" for git:dfe1725c3993d78dea18147fcfe472cf815a457d…
Project directory: /home/<USER:545ea5384610>/Praca/.pi
[2026-07-19T05:21:46.376Z] [magic-context][pi] subagent child detected (MAGIC_CONTEXT_PI_SUBAGENT=1); skipping full extension registration
[2026-07-19T05:21:56.270Z] [dreamer] classify chunk failed: Error message="classify manifest missing id 65" {"stackHead":"Error: classify manifest missing id 65 | at assertManifestCoversExactly (<HOME>/.pi/agent/tmp/extensions/npm/f35b2129/<USER:545ea5384610>_modules/@cortexkit/pi-magic-context/dist/index.js:198863:1061) | at applyClassifications (<HOME>/.pi/agent/tmp/extensions/npm/f35b2129/<USER:545ea5384610>_modules/@cortexkit/pi-magic-context/dist/index.js:198912:5103) | at classifyOneChunk (<HOME>/.pi/agent/tmp/extensions/npm/f35b2129/<USER:545ea5384610>_modules/@cortexkit/pi-magic-context/dist/index.js:198912:4321)"}
[2026-07-19T05:21:56.270Z] [dreamer] classify: stage=2 classified=0 changed=0 chunks=1
[2026-07-19T05:21:56.277Z] [dreamer] classify-memories: stage=2 classified=0 changed=0 chunks=1
[2026-07-19T05:21:56.283Z] [magic-context][pi-status] /ctx-dream: ## /ctx-dream
Ran: classify-memories
[2026-07-19T05:22:14.935Z] [dreamer] timer tick (startup) — projects=1
[2026-07-19T05:22:15.588Z] [git-commits] sweep starting for git:dfe1725c3993d78dea18147fcfe472cf815a457d (sinceDays=365 maxCommits=2000)
[2026-07-19T05:22:15.611Z] [git-commits] read 1 commits for git:dfe1725c3993d78dea18147fcfe472cf815a457d (sinceMs=1784403960000 latestIndexed=1784404020000)
[2026-07-19T05:22:15.613Z] [git-commits] indexed git:dfe1725c3993d78dea18147fcfe472cf815a457d: scanned=1 inserted=0 updated=0 evicted=0 embedded=0
[2026-07-19T05:22:15.623Z] [git-commits] sweep finished for git:dfe1725c3993d78dea18147fcfe472cf815a457d in 35ms: scanned=1 inserted=0 updated=0 evicted=0 embedded=0 drained=0 backlogDrained=0
[2026-07-19T05:22:15.630Z] [dreamer] OpenCode DB not found at <HOME>/.local/share/opencode/opencode.db — skipping OpenCode history scan
Activity
ualtinok commentedon Jul 20, 2026
Root cause found and fixed. The dreamer's model-fallback retry executor reused the same request body object across attempts; when a failing first attempt's prompt facade consumed the body, the retry attempt spawned the Pi child without the task's
systemprompt, andpi --printthen fell back to your persisted mode prompt — which is why your extension's Ask-mode prompt scored the pool. classify-memories was the visible victim because it was the one task hitting model-fallback retries on your setup (the other tasks succeeded first-try, so their prompts survived).Two fixes land together: retry attempts now snapshot the original body (every attempt carries the task's own system prompt), and the Pi runner refuses to spawn a zero-tool agent (classifier/reviewer) with an empty system prompt at all — that shape can never be correct, so it now fails as a transient task error instead of silently running with whatever Pi has persisted.
Ships in the next patch release (v0.32.4). Thank you for the unusually good diagnosis — the
pi -ne --extensionisolation run and the prompt-monitoring narrowed this to exactly the right layer.tenshiak commentedon Jul 20, 2026
Unfortunately, the issue is still present in v0.32.4. It still uses that "Ask mode" prompt for some reason, even though I didn't use that mode in days. Fresh log:
tenshiak commentedon Jul 20, 2026
I found the culprit. It actually WAS my extension. There are a few things I didn't consider and missed. Maybe they can be used to improve the system.
pi -ne --extension "npm:@cortexkit/pi-magic-context@0.32.3", magic-cortex's subagents start a new pi process that loads the default config. I should have thought about that.That means there is a bug in my extension, and I will investigate it on my own. It showed a feature request worth thinking over: don't start the subagents with extensions besides magic-context. But it could be an issue because someone could use extensions to implement custom providers not supported by PI. It could be solved with proper configuration, though.
I still don't understand why it only overwrote this one specific task's prompt.
tenshiak commentedon Jul 20, 2026
It was my pi-modes extension. It was an early exit when there were no tools active and remained on "ask" mode (first alphabetically), before switching it to the default "edit" mode. I'll close the issue.