Repository navigation
docs(react-core): clarify system_prompt requirements for useFrontendTool - #5469
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@nuthalapativarun is attempting to deploy a commit to the CopilotKit Team on Vercel. A member of the Team first needs to authorize it. |
|
Just bumping this — the system_prompt docs clarification for useFrontendTool should be a quick read whenever someone has a few minutes. The Vercel check failure is just the auth-gated preview deploy for fork PRs, not an actual build issue. Thanks! |
|
Thanks @nuthalapativarun — content looks reasonable. Two items:
|
BenTaylorDev
left a comment
There was a problem hiding this comment.
Thanks — the thesis is valuable and (nice) it's correctly authored against the current showcase/shell-docs/src/content/ tree and merges clean. But the code examples don't match the shipped API and wouldn't run as written:
- They use
from langgraph.prebuilt import create_react_agentwith amiddleware=kwarg — but in the pinned langchain 1.x,middleware=belongs tocreate_agent(langchain.agents), notcreate_react_agent; as written this likely raisesTypeError. Every example on main usescreate_agent/createAgent. - They pass
prompt=/prompt:for the system prompt, which both contradicts the PR's own headline ("add it tosystem_prompt") and isn't the current param (system_prompt=/systemPrompt:). - The TypeScript example imports
copilotkitMiddlewarebut never attaches it (nomiddleware:array) — so frontend tools wouldn't actually reach the agent in that snippet. - The added "Imperatively emitting tool calls" section links to
/langgraph/advanced/emit-api-hook-mapping, which doesn't exist on main (dead link), and is scope creep beyond #4950 (system_prompt guidance).
Please align the examples with the current pinned API (create_agent/createAgent + system_prompt=/systemPrompt:, matching main.py/agent.ts), actually wire copilotkitMiddleware into the TS middleware: array, and either drop the emit section or fix its link. The prose is close — it's the examples that need to be made accurate and runnable.
…rent SDK Switch the code samples from create_react_agent(middleware=..., prompt=...) to create_agent/createAgent with system_prompt/systemPrompt, matching the current pinned langchain 1.x API used elsewhere in the docs. Wire copilotkitMiddleware into the TypeScript example's middleware array (it was imported but never attached). Point the "Imperatively emitting tool calls" link at the correct /integrations/langgraph/ prefixed route. Addresses review feedback on CopilotKit#5469.
|
Thanks for the detailed review! Pushed a fix that:
Since you flagged these two as coupled, happy to have them merge together. |
BenTaylorDev
left a comment
There was a problem hiding this comment.
Thanks — the API examples are now correct in both languages (create_agent/createAgent, system_prompt/systemPrompt, and the TS example actually attaches copilotkitMiddleware), matching the in-repo reference agents, and the docs are correctly under showcase/shell-docs. One item remains: the "Imperatively emitting tool calls from agent code" section still links to /integrations/langgraph/advanced/emit-api-hook-mapping, which doesn't exist on main (you fixed the URL prefix, but the target page isn't there). That page is the one #5483 creates — so either drop this section (it's outside the system_prompt scope of this PR) or sequence it to land after #5483 so the link resolves. Everything else looks good.
BenTaylorDev
left a comment
There was a problem hiding this comment.
Re-reviewed against current main. The one item I left open has resolved itself — #5483 merged about nine minutes after my last review, so /integrations/langgraph/advanced/emit-api-hook-mapping now exists on main, the link text matches that page's title verbatim, and the page does cover copilotkit_emit_tool_call and copilotkit_customize_config as promised. That was the sequencing option I offered, so nothing is left for you to do here. Sorry for the wait — the blocker expired the same afternoon I wrote it.
Everything else I checked holds up:
- API accuracy — I verified the snippets against the pinned wheels, not just by eye.
create_agent(model=, tools=, middleware=, state_schema=, system_prompt=)matcheslangchain/agents/factory.pyexactly;CopilotKitMiddlewareandCopilotKitStateare real top-levelcopilotkitexports; the Python example matchesexamples/integrations/langgraph-python/agent/main.pyline for line, imports included. The TypeScript example matchesexamples/integrations/langgraph-js/agent/src/agent.ts, andcopilotkitMiddlewareis genuinely wired intomiddleware:now.stateSchema: CopilotKitStateSchemais valid — it's a realStateSchemainstance. - Placement — correctly authored under
showcase/shell-docs/src/content/, and it merges into currentmainclean despite the branch being stale. - Conventions —
<Tabs groupId="language_langgraph_agent" … persist>,<Callout>, and the[!code highlight:N]transformer all match what the surrounding pages already do. The anchor the two cross-links point at matches the new heading.
Two nits, neither blocking, both fine to leave:
model="openai:gpt-4o"— these docs otherwise useopenai:gpt-5.4.- The
[!code highlight:7]/:6ranges each stop one line short, so the closing line of each block isn't highlighted.
One note for anyone reading this later, not a request: the # Works the same for "create_react_agent" or similar options comment isn't actually true — in the pinned langgraph, create_react_agent takes neither middleware nor system_prompt and raises on both. That comment already ships on main in two other files, so you were following the house style and this PR isn't the place to fix it; I'll file the tree-wide cleanup separately.
The prose is genuinely useful — the "description tells the model what, system_prompt tells it when" framing plus the decision table is the right shape for #4950. Thanks for sticking with this through two rounds.
I bless the code with a glad heart 🙏
|
Note: 2 failing tests are caused by the stale main base and are fixed on main, and these changes are docs-only and so wouldn't run afoul of them. |
…t" comments (7 sites) (#6614) Closes #6607. Verified against the pinned `langgraph_prebuilt` (1.1.0): `create_react_agent` has neither `middleware` nor `system_prompt` parameters, rejects `state_schema=CopilotKitState`, and is deprecated in favour of `langchain.agents.create_agent`. Readers following the comment hit an immediate `TypeError`. All 7 occurrences on `main` are updated (4 sites noted in the issue plus the 3 that landed with #5469): - `showcase/shell-docs/src/content/docs/integrations/langgraph/agent-app-context.mdx` (Python + TypeScript) - `showcase/shell-docs/src/content/docs/integrations/langgraph/frontend-tools.mdx` (Python + TypeScript) - `showcase/shell-docs/src/content/snippets/integrations/langgraph/frontend-tools.mdx` (Python + TypeScript) - `showcase/shell-docs/src/content/reference/hooks/useFrontendTool.mdx` (Python) Each comment is replaced with an accurate note (”`create_agent` supersedes the deprecated `create_react_agent`, which accepts neither `middleware=` nor `system_prompt=`”), and the TypeScript snippets now reference `createReactAgent` (camelCase) instead of the Python `create_react_agent` name — the second, smaller problem noted in the issue.
What does this PR do?
Adds documentation explaining that
useFrontendToolmay require explicitsystem_promptguidance in LangGraph agents to be reliably called. Includes a working code example showing both a well-describeduseFrontendToolregistration and the matching system prompt instruction. Addresses the confusion reported in #4950 where users implement tools with only adescriptionand find the agent doesn't call them.Changes:
docs/integrations/langgraph/frontend-tools.mdx— new section "Ensuring your agent reliably calls frontend tools" with aCallout, Python+TypeScript code examples, and a decision table (description vs. system_prompt)reference/hooks/useFrontendTool.mdx— added "LangGraph agents: description vs. system_prompt" subsection linking to the full exampledocs/troubleshooting/common-issues.mdx— expanded the "tool listed but agent never calls it" bullet to cross-link the new guideRelated PRs and Issues
Checklist