Skip to content

Conversation

sydney-runkle
Copy link
Contributor

@sydney-runkle sydney-runkle commented Sep 19, 2025

In Python we're now exposing decorators that can be used to generate simple middlewares w/ one hook.

TBD what we're doing in JS.

@Copilot Copilot AI review requested due to automatic review settings September 19, 2025 00:18
@github-actions github-actions bot added langchain For docs changes to LangChain oss labels Sep 19, 2025
Copy link
Contributor

@Copilot 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 documentation for dynamic system prompts using middleware in LangChain agents. The feature allows developers to modify system prompts dynamically at runtime based on context or agent state.

  • Adds DynamicSystemPromptMiddleware documentation to the middleware page with comprehensive examples
  • Integrates dynamic prompt examples into the agents page to show practical usage
  • Updates navigation and cross-references between middleware and agents documentation

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/oss/langchain/middleware.mdx Adds complete documentation section for DynamicSystemPromptMiddleware with examples for both context-based and conversation-length-based prompts
src/oss/langchain/agents.mdx Adds a subsection on dynamic prompts with middleware to show integration with agent creation

Copy link

Preview ID generated: preview-srdyna-1758241143-49d6752

Co-authored-by: Christian Bromann <[email protected]>
@Copilot Copilot AI review requested due to automatic review settings September 19, 2025 01:32
Copy link
Contributor

@Copilot 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

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

Copy link

Preview ID generated: preview-srdyna-1758245605-9bcb701

@Copilot Copilot AI review requested due to automatic review settings September 19, 2025 19:13
Copy link
Contributor

@Copilot 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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Copy link

Preview ID generated: preview-srdyna-1758309488-c704e9e

Copy link

Preview ID generated: preview-srdyna-1758663482-f8412db

@Copilot Copilot AI review requested due to automatic review settings September 23, 2025 21:39
Copy link
Contributor

@Copilot 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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Copy link

Preview ID generated: preview-srdyna-1758663628-24b4adb

@Copilot Copilot AI review requested due to automatic review settings September 24, 2025 20:19
Copy link
Contributor

@Copilot 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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Copy link

Preview ID generated: preview-srdyna-1758745243-7ad6f94

@Copilot Copilot AI review requested due to automatic review settings September 24, 2025 20:22
Copy link
Contributor

@Copilot 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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.


```python
from typing import TypedDict

Copy link
Preview

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

The import order doesn't follow Python conventions. Standard library imports should come first, followed by third-party imports, then local imports. Move from typing import TypedDict to the top of the imports section.

Suggested change

Copilot uses AI. Check for mistakes.

user_role: str

@modify_model_request
def dynamic_system_prompt(state: AgentState, request: ModelRequest, runtime: Runtime[Context]) -> ModelRequest:
Copy link
Preview

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

The ModelRequest type is referenced but never imported or defined in the example. This will cause import errors when users try to run the code. Add the necessary import statement.

Copilot uses AI. Check for mistakes.


const agent = createAgent({
model: "openai:gpt-4o",
tools: [...],
Copy link
Preview

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

The ellipsis [...] in the tools array is unclear and not valid TypeScript syntax. Replace with a comment like // your tools here or show actual tool examples for clarity.

Suggested change
tools: [...],
tools: [/* your tools here */],

Copilot uses AI. Check for mistakes.

user_role: str

@modify_model_request
def dynamic_system_prompt(state: AgentState, request: ModelRequest, runtime: Runtime[Context]) -> ModelRequest:
Copy link
Preview

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

Similar to the middleware.mdx file, the ModelRequest type is used without being imported. Add the necessary import statement to make this example runnable.

Copilot uses AI. Check for mistakes.


const agent = createAgent({
model: "openai:gpt-4o",
tools: [/* ... */],
Copy link
Preview

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

The comment /* ... */ in the tools array should be more descriptive. Consider using /* your tools here */ or provide an actual example tool to make the documentation more helpful.

Suggested change
tools: [/* ... */],
tools: [
{
name: "calculator",
description: "Performs basic arithmetic operations",
func: async ({ a, b }) => a + b,
},
],

Copilot uses AI. Check for mistakes.

Copy link

Preview ID generated: preview-srdyna-1758745406-14f2e46

@sydney-runkle sydney-runkle merged commit 9f08cf8 into main Sep 24, 2025
12 checks passed
@sydney-runkle sydney-runkle deleted the sr/dynamic-prompt branch September 24, 2025 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
langchain For docs changes to LangChain oss
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants