Repository navigation
fix(agent): report the system prompt before a session's first message - #974
Merged
agegr merged 3 commits intoSep 30, 2026
Merged
Conversation
`get_state` read `agent.state.systemPrompt`, which Pi 0.86 turned into a getter that replays the transcript. A session that has not run anything yet has no system message to replay, so the field came back as "" and the System panel rendered its "prompt is empty (tools are disabled)" state for every brand-new session. Read the session-level getter instead. It renders the prompt from the current options, which are populated while the session is built, so it is already correct before the first run; its meaning did not change in 0.86, and it is what the old `_baseSystemPrompt` field held. Fixes agegr#973
The session getter renders the prompt from the base options, so after a run it drops the sections a before_agent_start handler changed for that run. Report the transcript replay when it has a prompt and fall back to the getter only while it is still empty. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Owner
|
Thanks @wyx20021207-create! #973 is real: the SDK builds the agent with I pushed one change on top of your commit:
The getter exists unchanged in pi 0.99, so this carries over to the upgrade. Generated by Claude Code |
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 6, 2026
…agegr#974) * fix(agent): report the system prompt before a session's first message `get_state` read `agent.state.systemPrompt`, which Pi 0.86 turned into a getter that replays the transcript. A session that has not run anything yet has no system message to replay, so the field came back as "" and the System panel rendered its "prompt is empty (tools are disabled)" state for every brand-new session. Read the session-level getter instead. It renders the prompt from the current options, which are populated while the session is built, so it is already correct before the first run; its meaning did not change in 0.86, and it is what the old `_baseSystemPrompt` field held. Fixes agegr#973 * fix(agent): keep the replayed system prompt once a run has recorded one The session getter renders the prompt from the base options, so after a run it drops the sections a before_agent_start handler changed for that run. Report the transcript replay when it has a prompt and fall back to the getter only while it is still empty. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Alex Yang <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 8, 2026
…agegr#974) * fix(agent): report the system prompt before a session's first message `get_state` read `agent.state.systemPrompt`, which Pi 0.86 turned into a getter that replays the transcript. A session that has not run anything yet has no system message to replay, so the field came back as "" and the System panel rendered its "prompt is empty (tools are disabled)" state for every brand-new session. Read the session-level getter instead. It renders the prompt from the current options, which are populated while the session is built, so it is already correct before the first run; its meaning did not change in 0.86, and it is what the old `_baseSystemPrompt` field held. Fixes agegr#973 * fix(agent): keep the replayed system prompt once a run has recorded one The session getter renders the prompt from the base options, so after a run it drops the sections a before_agent_start handler changed for that run. Report the transcript replay when it has a prompt and fall back to the getter only while it is still empty. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Alex Yang <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
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
get_statereportedagent.state.systemPrompt, which Pi 0.86 turned into a getter that replays the transcript's system messages. A session that has not run anything yet has no message to replay, so the field came back as""— andSystemPromptPanelrendersprompt === ""as "System prompt is empty (tools are disabled)", a state meant for Chat-only sessions. Every brand-new session therefore claimed its tools were disabled until the first message was sent. Sessions that already have messages were unaffected, which is why this only shows up on a fresh session.Fixes #973.
How
AgentSession.systemPromptrenders the prompt from the current options and is populated while the session is built (_buildRuntime→_refreshToolRegistry→setActiveToolsByName→_rebuildSystemPrompt), so it is already correct before the first run. Its meaning did not change in 0.86 — it is what the old_baseSystemPromptfield held. The exact-prompt branch is untouched, so Chat-only sessions and replace-mode subagents keep reporting their projected prompt.Verification
The empty string is the whole bug — one brand-new session, nothing sent, the same prompt read two ways:
agent.state.systemPrompt(whatget_stateread before)""AgentSession.systemPrompt(what it reads now)startRpcSession()and readingget_stateon a brand-new session with no message sent now returns the full rendered prompt — preamble, tool list, skills, cwd — instead of"". On that same sessionagent.state.systemPromptis still"".get_state reports the prompt of a session that has not run anything yetcovers the empty-transcript case. It fails onmainand passes with the change.agent.state.systemPrompttoinner.systemPrompt— which is also what extensions rewrite when they are bound, so it still tests what its name says.npm run lintandnpx tsc --noEmitare clean.npm test: identical results tomain— the same pre-existing failures (FileViewer, terminal PTY, symlink and PATH tests; all Windows-only), no new ones.