Skip to content

fix(deepagents): keep forked subagents on the parent's prompt-cache prefix - #1081

Open
Mason Daugherty (mdrxy) wants to merge 1 commit into
mainfrom
mdrxy/sdk/fork-instructions-in-task
Open

Mason Daugherty (mdrxy) wants to merge 1 commit into
mainfrom
mdrxy/sdk/fork-instructions-in-task

Conversation

@mdrxy

Copy link
Copy Markdown
Member

Forked subagents now reuse the parent agent's prompt cache when the fork sets its own systemPrompt. Ports langchain-ai/deepagents#7628.


A fork's own systemPrompt was appended to the parent's system prompt, so the fork's request diverged before the inherited history and re-cached all of it:

before
parent: [tools][system          ][history…]
fork:   [tools][system + fork's ][history…][task]
                       ↑ differs here

after
parent: [tools][system][history…]
fork:   [tools][system][history…][fork's instructions + task]
                                  ↑ first difference
  • A fork's system prompt is now exactly the parent's.
  • The fork's systemPrompt goes in its task message, after the fork preamble and before the task description, matching Python.

Behavior change: fork instructions arrive in the final user message instead of the system prompt; their text is unchanged. A SystemMessage systemPrompt is passed as its text.

@vercel

vercel Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
deepagentsjs-ui Ready Ready Preview Nov 18, 2026 5:18pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5e48984

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
deepagents Patch
deepagents-acp Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Nov 18, 2026

Copy link
Copy Markdown

Open in StackBlitz

deepagents-acp

npm i https://pkg.pr.new/deepagents-acp@1081

deepagents

npm i https://pkg.pr.new/deepagents@1081

@langchain/sandbox-standard-tests

npm i https://pkg.pr.new/@langchain/sandbox-standard-tests@1081

@langchain/daytona

npm i https://pkg.pr.new/@langchain/daytona@1081

@langchain/deno

npm i https://pkg.pr.new/@langchain/deno@1081

@langchain/modal

npm i https://pkg.pr.new/@langchain/modal@1081

@langchain/node-vfs

npm i https://pkg.pr.new/@langchain/node-vfs@1081

@langchain/quickjs

npm i https://pkg.pr.new/@langchain/quickjs@1081

commit: 5e48984

@robin-agent robin-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Robin Review: No issues found

Robin reviewed this PR and found no potential bugs to report.

Open in Robin

Mason Daugherty (mdrxy) added a commit to langchain-ai/docs that referenced this pull request Nov 18, 2026
Updates the forked-subagent docs: a fork's own `system_prompt` /
`systemPrompt` now goes in its task message instead of being appended to
the parent's system prompt, so the fork keeps the parent's prompt cache.

- Python: langchain-ai/deepagents#7628 (merged)
- JS: langchain-ai/deepagentsjs#1081 (open, merge before this ships for
JS)

Removes the "leave it unset" guidance, since the cache tradeoff no
longer applies.

Co-authored-by: Robin <open-swe@users.noreply.github.com>

This branch was successfully deployed

1 active deployment
Preview — 5e489846 Deployed Nov 18, 2026 by vercel[bot]
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