Skip to content

feat(acp): incorporate client systemPrompt into new sessions#9971

Draft
wpfleger96 wants to merge 4 commits into
mainfrom
wpfleger/acp-system-prompt
Draft

feat(acp): incorporate client systemPrompt into new sessions#9971
wpfleger96 wants to merge 4 commits into
mainfrom
wpfleger/acp-system-prompt

Conversation

@wpfleger96

@wpfleger96 wpfleger96 commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Reference implementation of RFD #1237, which is not yet merged. The RFD proposes systemPrompt as a first-class session/new field in ACP. Until it lands, this PR implements the same capability via _meta["systemPrompt"] — the ACP extensibility mechanism — so no fork or schema change is required and the PR is mergeable today.

Incorporates the client-provided system prompt into new sessions. When a client sends systemPrompt via _meta on session/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"] before args is moved into session configuration, then applied via extend_system_prompt after 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 _meta keeps the implementation self-contained: no typed schema field, no fork, no [patch.crates-io] entry. When RFD #1237 merges and systemPrompt becomes a first-class ACP field, this PR can be updated to read it directly from args instead of _meta.

Changes

  • crates/goose/src/acp/server/new_session.rsclient_system_prompt reads _meta["systemPrompt"] via meta_string (returns Result — propagates invalid-params error if the value is not a string); None, empty, and whitespace-only values yield None so 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.rssystem_prompt: Option<String> on Session, SessionUpdateBuilder, FromRow, create_schema, and apply_update. Schema version bumped 14→15 with idempotent ALTER TABLE sessions ADD COLUMN system_prompt TEXT migration.
  • crates/goose/src/execution/manager.rs — re-applies session.system_prompt via extend_system_prompt in create_agent_locked so the prompt is restored after LRU eviction or restart.
  • ui/desktop/openapi.json, ui/desktop/src/api/types.gen.tssystem_prompt field on the Session type.

Related

npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 and others added 3 commits June 25, 2026 14:54
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>
Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
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