chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 12:58:18 +08:00
commit 6d5d58c1a9
18293 changed files with 3502153 additions and 0 deletions
@@ -0,0 +1,23 @@
<Steps>
<Step>
### Install the LangGraph Python SDK
<InstallPythonSDK />
</Step>
<Step>
### Wire CopilotKit middleware into your graph
Agent config flows from the UI into the agent via `useAgentContext` — the
frontend publishes a typed object and `CopilotKitMiddleware` injects it
into the model's prompt on every turn. Make sure the middleware is in
your `create_agent` call.
<DemoCode file="src/agents/agent_config_agent.py" region="agent-config-setup" />
Read the resulting config inside your system prompt or a custom
middleware — see `src/agents/agent_config_agent.py` for the full
rulebook-driven shape used in the showcase.
</Step>
</Steps>
@@ -0,0 +1,19 @@
<Steps>
<Step>
### Install the LangGraph Python SDK
<InstallPythonSDK />
</Step>
<Step>
### Wire read-only agent context into your graph
`useAgentContext` publishes read-only UI values through
`CopilotKitMiddleware`. Attach the middleware to the agent and describe
how the model should use the frontend-supplied context in the system
prompt.
<DemoCode file="src/agents/readonly_state_agent_context.py" region="agent-context-setup" />
</Step>
</Steps>
@@ -0,0 +1,16 @@
First, add `CopilotKitMiddleware` to your `create_agent` call. The middleware
is what makes every CopilotKit feature on the frontend — frontend tools,
shared state, agent context, and generative UI components — visible to your
LangGraph agent on every turn.
<DemoCode file="src/agents/frontend_tools.py" region="middleware" />
<Accordions>
<Accordion title="Install the SDK">
If `copilotkit` isn't already in your project, add it so the import
above resolves. Pick the package manager that matches your project:
<InstallPythonSDK />
</Accordion>
</Accordions>
@@ -0,0 +1,18 @@
<Steps>
<Step>
### Install the LangGraph Python SDK
<InstallPythonSDK />
</Step>
<Step>
### Wire it into your graph
Import `CopilotKitMiddleware` and pass it to `create_agent`. This is the
single line of CopilotKit-specific setup; everything else is standard
LangGraph.
<DemoCode file="src/agents/frontend_tools.py" region="middleware" />
</Step>
</Steps>
@@ -0,0 +1,19 @@
<Steps>
<Step>
### Install the LangGraph Python SDK
<InstallPythonSDK />
</Step>
<Step>
### Wire CopilotKit middleware into your graph
Frontend tools registered with `useFrontendTool` are forwarded to your
agent at runtime. `CopilotKitMiddleware` is the bridge — drop it into
`create_agent`'s `middleware` list and the LLM sees the forwarded tool
definitions on every turn.
<DemoCode file="src/agents/frontend_tools.py" region="middleware" />
</Step>
</Steps>
@@ -0,0 +1,22 @@
<Steps>
<Step>
### Install the LangGraph Python SDK
<InstallPythonSDK />
</Step>
<Step>
### Wire CopilotKit middleware into your graph
For `useHumanInTheLoop` tool-based HITL, the tool is defined entirely on
the frontend and forwarded to the agent. `CopilotKitMiddleware` is what
forwards it — drop it into your `create_agent` call.
<DemoCode file="src/agents/frontend_tools.py" region="middleware" />
For the `useInterrupt` graph-paused pattern, you'll also use LangGraph's
native `interrupt(...)` primitive inside a graph node — no extra
CopilotKit setup beyond the middleware above.
</Step>
</Steps>
@@ -0,0 +1,24 @@
<Steps>
<Step>
### Install the LangGraph Python SDK
<InstallPythonSDK />
</Step>
<Step>
### Wire CopilotKit middleware into your graph
Programmatic control (`copilotkit.runAgent`, `agent.subscribe`,
`agent.addMessage`) drives runs through the same agent your chat UI
uses, so the backend wiring is the same one-line `CopilotKitMiddleware`
setup.
<DemoCode file="src/agents/frontend_tools.py" region="middleware" />
For the headless `useInterrupt` pattern, also use LangGraph's native
`interrupt(...)` inside a graph node and resume with
`forwardedProps: { command: { resume, interruptEvent } }` from the
frontend.
</Step>
</Steps>
@@ -0,0 +1,19 @@
<Steps>
<Step>
### Install the LangGraph Python SDK
<InstallPythonSDK />
</Step>
<Step>
### Wire CopilotKit middleware into your graph
Shared state flows between your UI and your agent through `agent.setState`
on the frontend and `state.get(...)` in your graph nodes. Attach
`CopilotKitMiddleware` to your `create_agent` call so CopilotKit-specific
state is picked up alongside your own.
<DemoCode file="src/agents/shared_state_read_write.py" region="shared-state-setup" />
</Step>
</Steps>
@@ -0,0 +1,18 @@
<Steps>
<Step>
### Install the LangGraph Python SDK
<InstallPythonSDK />
</Step>
<Step>
### Add state streaming middleware
`StateStreamingMiddleware` maps a tool argument to an agent state key and
forwards partial tool-call arguments as state updates while the model is
still generating.
<DemoCode file="src/agents/shared_state_streaming.py" region="state-streaming-middleware" />
</Step>
</Steps>
@@ -0,0 +1,21 @@
<Steps>
<Step>
### Install the LangGraph Python SDK
<InstallPythonSDK />
</Step>
<Step>
### Wire CopilotKit middleware into your graph
Sub-agents are wired as tools on a supervisor `create_agent` call. The
supervisor's middleware list includes `CopilotKitMiddleware()` so the
delegation log slot streams back to the UI through shared state.
<DemoCode file="src/agents/subagents.py" region="subagent-setup" />
See `src/agents/subagents.py` for the canonical supervisor + three
sub-agents pattern with a live delegation log.
</Step>
</Steps>