Skip to content

feat(provider): forward sessionOptions (systemPrompt, model, allowedTools, maxTurns) to runtime#23

Merged
DaniAkash merged 6 commits into
mainfrom
feat/provider-session-options
May 18, 2026
Merged

feat(provider): forward sessionOptions (systemPrompt, model, allowedTools, maxTurns) to runtime#23
DaniAkash merged 6 commits into
mainfrom
feat/provider-session-options

Conversation

@DaniAkash
Copy link
Copy Markdown
Owner

@DaniAkash DaniAkash commented May 11, 2026

Summary

Upstream: openclaw/acpx#309 — the runtime PR this provider change consumes.

Surfaces sessionOptions on AcpxProviderSettings and threads it through ensureHandle into runtime.ensureSession(...). Lets AI-SDK consumers set a per-session systemPrompt (or model / allowedTools / maxTurns) on a fresh ACP session without bypassing the runtime.

const provider = createAcpxProvider({
  agent: 'claude-code',
  cwd: process.cwd(),
  sessionOptions: {
    systemPrompt: 'You are an expert Rust reviewer. Be terse.',
    // or { append: 'Also propose tests.' }
    // model, allowedTools, maxTurns also supported
  },
})

System prompts are applied on newSession; changing them later requires a new session (use a distinct sessionKey or close the prior record first). This matches the upstream runtime contract added in openclaw/acpx#309.

What changed

File Change
package.json Version 0.0.40.0.5. acpx peer-dep + dev-dep raised to >=0.8.0 (the upstream version that ships AcpRuntimeEnsureInput.sessionOptions + SessionAgentOptions + SystemPromptOption via openclaw/acpx#309).
src/types.ts Add sessionOptions?: SessionAgentOptions to AcpxProviderSettings; re-export SessionAgentOptions + SystemPromptOption from acpx/runtime.
src/provider.ts Forward this.settings.sessionOptions from ensureHandle into runtime.ensureSession(...) (one line).
src/index.ts Re-export the two new types.
README.md New ### System prompts snippet under "Persistent sessions" explaining string vs { append } forms and the "fresh session only" semantics.
test/unit/session-options.test.ts NEW — three tests using MockAcpRuntime: (1) systemPrompt string flows through to ensureSession.sessionOptions, (2) { append } form + all four agent-option fields (model / allowedTools / maxTurns / systemPrompt) round-trip without mutation, (3) absent when not configured.

Test plan

  • bun run lint clean.
  • bun run typecheck clean (passes against the now-published acpx@0.8.0).
  • bun run fallow clean.
  • bun test — 266 pass / 24 skip / 0 fail across the monorepo (290 tests, 30 files; the three new tests are part of the 266).
  • bun run build clean (ESM + .d.ts).

Coordination

Ships alongside two sibling provider features that all target 0.0.5:

  • #17onPermissionRequest callback
  • #19getModels() helper

Whichever lands first wins 0.0.5; the other two will need a follow-up bump (0.0.50.0.60.0.7) and a one-line package.json rebase to resolve the version conflict. All three are independent on the code side.

Surfaces sessionOptions on AcpxProviderSettings and threads it through
ensureHandle into AcpRuntime.ensureSession. Lets AI SDK consumers set a
per-session systemPrompt (or model/allowedTools/maxTurns) on a fresh
ACP session without bypassing the runtime.

System prompts are applied at session/new time and persisted onto the
underlying record. Reusing an existing persistent session ignores
sessionOptions by design; callers who want a different prompt should
use a distinct sessionKey or close the prior session first.

Re-exports SessionAgentOptions and SystemPromptOption from acpx/runtime.

Drive-by: export RuntimeMcpServer type from mcp-servers.ts so the
exported toRuntimeMcpServers signature no longer references a same-file
private type (fixes a fallow regression introduced in #22).

Bumps acpx peer-dep floor to >=0.8.0 and bumps the package to 0.1.0.
Requires the matching runtime change from openclaw/acpx#309.
Resolves package.json version conflict: keep this branch's 0.1.0
bump (main is at 0.0.4; this PR ships new public API). provider.ts
auto-merged cleanly, including the markSessionKeyUsed() pattern
that landed on main in PR #26.

Resyncs bun.lock against acpx@0.8.0 — now published with
AcpRuntimeEnsureInput.sessionOptions, SessionAgentOptions, and
SystemPromptOption that this PR forwards / re-exports.
@DaniAkash DaniAkash marked this pull request as ready for review May 17, 2026 07:11
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support in acpx-ai-provider for passing per-session agent configuration (sessionOptions) through the provider into acpx/runtime.ensureSession(...), enabling callers to set systemPrompt (and related options) when creating a fresh ACP session.

Changes:

  • Add sessionOptions?: SessionAgentOptions to AcpxProviderSettings and re-export related runtime types.
  • Forward sessionOptions into runtime.ensureSession(...) during handle/session initialization.
  • Document the feature and add unit tests validating the forwarded payload.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/acpx-ai-provider/test/unit/session-options.test.ts Adds unit tests asserting sessionOptions forwarding behavior.
packages/acpx-ai-provider/src/types.ts Adds sessionOptions to provider settings; re-exports SessionAgentOptions/SystemPromptOption.
packages/acpx-ai-provider/src/provider.ts Threads sessionOptions into runtime.ensureSession(...).
packages/acpx-ai-provider/src/index.ts Re-exports the new types from the package entrypoint.
packages/acpx-ai-provider/README.md Documents system prompt / per-session options behavior and semantics.
packages/acpx-ai-provider/package.json Bumps version and raises acpx dependency constraints.
bun.lock Updates lockfile for new acpx version and workspace metadata.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/acpx-ai-provider/README.md Outdated
Comment thread packages/acpx-ai-provider/src/types.ts Outdated
Comment thread packages/acpx-ai-provider/package.json Outdated
…n record

The 'close the prior session first' guidance was misleading: AcpxProvider.close()
passes discardPersistentState: false, so the next ensureSession for the same
sessionKey reloads the record and ignores the new sessionOptions. A distinct
sessionKey is the only way to apply a different systemPrompt for the same
workspace.
DaniAkash added 2 commits May 18, 2026 18:36
Brings acpx-ai-provider in line with the sibling acp-probe package which
uses a caret-pin on acpx. Peer dep stays at >=0.8.0 to express the
minimum supported runtime version.
…-options

# Conflicts:
#	bun.lock
#	packages/acpx-ai-provider/package.json
@DaniAkash DaniAkash merged commit 05745e4 into main May 18, 2026
1 check was waiting
@DaniAkash DaniAkash deleted the feat/provider-session-options branch May 18, 2026 13:09
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.

2 participants