feat(acp): incorporate client systemPrompt into new sessions#9971
Draft
wpfleger96 wants to merge 4 commits into
Draft
feat(acp): incorporate client systemPrompt into new sessions#9971wpfleger96 wants to merge 4 commits into
wpfleger96 wants to merge 4 commits into
Conversation
session/new now reads _meta["systemPrompt"] and applies it additively to the agent's system prompt under a dedicated key, leaving goose's own instructions intact. Empty and whitespace-only values are ignored so the default prompt is unchanged. systemPrompt is passed via _meta per the ACP extensibility convention (ACP+ / _meta approach) rather than a typed schema field, so no fork or [patch.crates-io] entry is needed. Incorporation is an infallible literal insert, so the RFD's error clause holds vacuously and no error path is added. Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
The in-memory extend_system_prompt call was lost after agent LRU eviction, restart, or session/load. Persist the value to the sessions table (migration v15) and re-apply it in create_agent_locked so the prompt survives the full session lifecycle. Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
Migration v15 now checks pragma_table_info before ALTER TABLE (matching the v12-14 pattern) so tests that create a full schema then demote the version no longer crash on duplicate column. Reformatted the extend_system_prompt call in manager.rs and regenerated openapi.json + types.gen.ts. Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
0fb1839 to
e1b4707
Compare
Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
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.
Incorporates the client-provided system prompt into new sessions. When a client sends
systemPromptvia_metaonsession/new, goose adds it to the session's system prompt additively, alongside its own built-in instructions, rather than replacing them. The value is persisted to SQLite and re-applied when an evicted agent is recreated, so the prompt survives the full session lifecycle.The field is read from
_meta["systemPrompt"]beforeargsis moved into session configuration, then applied viaextend_system_promptafter the agent exists (past recipe application) under a key distinct from the recipe's, so neither overwrites the other. Empty and whitespace-only values are treated as absent, leaving the default system prompt unchanged.Using
_metakeeps the implementation self-contained: no typed schema field, no fork, no[patch.crates-io]entry. When RFD #1237 merges andsystemPromptbecomes a first-class ACP field, this PR can be updated to read it directly fromargsinstead of_meta.Changes
crates/goose/src/acp/server/new_session.rs—client_system_promptreads_meta["systemPrompt"]viameta_string(returnsResult— propagates invalid-params error if the value is not a string);None, empty, and whitespace-only values yieldNoneso the default prompt is unchanged. Applied after the agent is built and persisted to the session; unit tests for present, absent, whitespace-only, and empty-string inputs.crates/goose/src/session/session_manager.rs—system_prompt: Option<String>onSession,SessionUpdateBuilder,FromRow,create_schema, andapply_update. Schema version bumped 14→15 with idempotentALTER TABLE sessions ADD COLUMN system_prompt TEXTmigration.crates/goose/src/execution/manager.rs— re-appliessession.system_promptviaextend_system_promptincreate_agent_lockedso the prompt is restored after LRU eviction or restart.ui/desktop/openapi.json,ui/desktop/src/api/types.gen.ts—system_promptfield on the Session type.Related
systemPromptas a first-class ACP field (not yet merged)systemPromptinto_metawhen the target agent is goose