feat(examples-chat): Phase 2B — tool calls + citations#220
Merged
Conversation
…+ attach_citations)
Layers tool calls and citations onto the canonical demo by extending the python graph from a single-node generate to a ReAct-style loop with a dedicated tools node and a terminal attach_citations post-process. One welcome suggestion exercises both surfaces. The chat composition auto-renders both <chat-tool-calls> (auto-mounted in <chat>) and <chat-citations> (auto-mounted in <chat-message>) so the Angular UI surface needs no changes. Phase 2B is ~120 LOC mostly Python: hardcoded 5-document corpus, search_documents tool, should_continue conditional, ToolNode wiring, attach_citations node (uses RemoveMessage + AIMessage with same id to attach additional_kwargs.citations from the most recent ToolMessage batch). Two pytest smokes pin graph topology and tool return shape. CHECKLIST gets two newly populated sections. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Five-phase plan: branch; python TDD (failing topology + tool tests then implement corpus + tool + ReAct loop + attach_citations terminal node); welcome suggestion entry; CHECKLIST additions; verification + PR. ~120 LOC, 3 commits. Server-side probe verifies tool flow ends with an AI message carrying additional_kwargs.citations. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Layers tool calls and citations onto the canonical demo by extending the python graph from a single-node
generateinto a ReAct-style loop with a dedicatedtoolsnode and a terminalattach_citationspost-process.__start__ → generate → [tool_calls?] → tools → generate (loop)or→ attach_citations → __end__. Hardcoded 5-document Angular corpus (signals, RxJS interop, control flow, standalone, zoneless) + asearch_documentstool. Theattach_citationsnode walks back to the most recent ToolMessage, parses its JSON content, and replaces the final AI message with one carryingadditional_kwargs.citationspopulated (RemoveMessage + AIMessage with same id — standard LangGraph in-place edit pattern).The chat composition's
<chat-tool-calls>and<chat-citations>primitives already auto-render — no Angular UI changes needed. The@ngaf/langgraphadapter already populatesMessage.toolCallsfromtool_calls/ToolMessage pairs andMessage.citationsfromadditional_kwargs.citations.System prompt extended to encourage tool use on Angular topics with inline
[1],[2]citations.Spec:
docs/superpowers/specs/2026-05-08-canonical-chat-demo-phase-2b-tools-citations-design.mdPlan:
docs/superpowers/plans/2026-05-08-canonical-chat-demo-phase-2b-tools-citations.mdPhase 3+ (interrupts, subagents, generative UI, time travel, multi-thread) are separate spec/plan/PR cycles.
Test plan
Verified locally
nx run examples-chat-python:smoke— 4 passed (2 existing + 2 new)nx run examples-chat-angular:test— 9 passednx run examples-chat-angular:lint— 0 errorsnx run examples-chat-angular:build— succeeds (development)additional_kwargs.citationspopulated with 3 distinct sources (Signals — Angular guide, RxJS interop with signals, Built-in control flow).Pending visual verification
examples/chatdemo. Tool-call card renders during streaming, collapses to "complete" pill; sources panel renders below the response with citations; inline[1],[2]markers in message body link to sources.(Visual sweep continues against issue #214; rolls together with the next iteration.)