Skip to content

feat(sdk): improve system prompt configurability - #4437

Merged
ccurme (ccurme) merged 11 commits into
mainfrom
cc/system-prompt-config
Jul 3, 2026
Merged

feat(sdk): improve system prompt configurability#4437
ccurme (ccurme) merged 11 commits into
mainfrom
cc/system-prompt-config

Conversation

@ccurme

@ccurme ccurme (ccurme) commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

We introduce a minimal structured representation of the base system prompt and widen the type for system_prompt in create_deep_agent to allow users to specify it:

class SystemPromptConfig(TypedDict, total=False):
    prefix: str | SystemMessage | None   # before base
    base: str | SystemMessage | None      # omitted --> built-in base prompt
    suffix: str | SystemMessage | None    # after base


def create_deep_agent(
    ...,
    system_prompt: str | SystemMessage | SystemPromptConfig | None = None,
    ...,
): ...

Usage patterns:

create_deep_agent(...)  # keep default base (unchanged)

create_deep_agent(..., system_prompt="...")  # prepends default base (unchanged)

create_deep_agent(..., system_prompt={"base": "..."})  # overwrites default base (new)

create_deep_agent(..., system_prompt={"base": None})  # no system prompt except from middleware

create_deep_agent(..., system_prompt={"prefix": "...", "suffix": "..."})  # sandwiches the default base prompt

The primary motivation here is to let users modify the base prompt BASE_AGENT_PROMPT = """You are a deep agent..., which is currently fixed:

  • It contains statements around identity that may not hold for all applications (e.g., “You are a deep agent”)
  • It includes some guidance that may not be appropriate in all situations (e.g., asking for clarification)

We also expose a rendering function render_system_prompt which takes a SystemPromptConfig and builds the prompt. We use this in deepagents-code to clean up regex parsing that was used to modify the ### Model Identity section of the prompt during model switches. We can now build it into "suffix" (or "prefix" if desired) and assemble the prompt. This ends up moving the location of the ### Model Identity section.
^ deferring this

@github-actions github-actions Bot changed the title feat(deepagents): improve system prompt configurability feat(sdk): improve system prompt configurability Jul 2, 2026
@github-actions github-actions Bot added dcode Related to `deepagents-code` deepagents Related to the `deepagents` SDK / agent harness feature New feature/enhancement or request for one internal User is a member of the `langchain-ai` GitHub organization size: L 500-999 LOC labels Jul 2, 2026
@codspeed-hq

codspeed-hq Bot commented Jul 2, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 21 untouched benchmarks
⏩ 79 skipped benchmarks1


Comparing cc/system-prompt-config (8a0007e) with main (de2f7d2)

Open in CodSpeed

Footnotes

  1. 79 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@open-swe open-swe 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.

Open SWE Review found 1 potential issue.

Open in WebView Open SWE trace

Comment thread libs/code/deepagents_code/agent.py Outdated
@ccurme ccurme (ccurme) changed the title feat(sdk): improve system prompt configurability feat(deepagents,code): improve system prompt configurability Jul 2, 2026
@github-actions github-actions Bot changed the title feat(deepagents,code): improve system prompt configurability feat(sdk,code): improve system prompt configurability Jul 2, 2026
@github-actions github-actions Bot added size: M 200-499 LOC and removed size: L 500-999 LOC labels Jul 2, 2026
@ccurme ccurme (ccurme) changed the title feat(sdk,code): improve system prompt configurability feat(sdk): improve system prompt configurability Jul 3, 2026
@ccurme
ccurme (ccurme) merged commit 56c5a5e into main Jul 3, 2026
106 of 108 checks passed
@ccurme
ccurme (ccurme) deleted the cc/system-prompt-config branch July 3, 2026 02:09
Hunter Lovell (hntrl) added a commit to langchain-ai/deepagentsjs that referenced this pull request Jul 13, 2026
Mason Daugherty (mdrxy) added a commit that referenced this pull request Jul 14, 2026
… prompt (#4516)

Depends on alpha release of new SDK changes

dcode's system prompt appears as though it was intended to replace the
base system prompt instead of augmenting it (some of the sections are
almost identical).

#4437 introduced a
mechanism to overwrite the base prompt. Here we apply it in dcode.

Review system prompt snapshot for effective changes.

---------

Co-authored-by: Mason Daugherty <mason@langchain.dev>
Co-authored-by: Mason Daugherty <github@mdrxy.com>
Hunter Lovell (hntrl) added a commit to langchain-ai/deepagentsjs that referenced this pull request Jul 24, 2026
Marcelo5444 pushed a commit to Marcelo5444/deepagents that referenced this pull request Jul 30, 2026
Marcelo5444 pushed a commit to Marcelo5444/deepagents that referenced this pull request Jul 30, 2026
… prompt (langchain-ai#4516)

Depends on alpha release of new SDK changes

dcode's system prompt appears as though it was intended to replace the
base system prompt instead of augmenting it (some of the sections are
almost identical).

langchain-ai#4437 introduced a
mechanism to overwrite the base prompt. Here we apply it in dcode.

Review system prompt snapshot for effective changes.

---------

Co-authored-by: Mason Daugherty <mason@langchain.dev>
Co-authored-by: Mason Daugherty <github@mdrxy.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dcode Related to `deepagents-code` deepagents Related to the `deepagents` SDK / agent harness feature New feature/enhancement or request for one internal User is a member of the `langchain-ai` GitHub organization size: M 200-499 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant