Skip to content

feat(examples-chat): Phase 2B — tool calls + citations#220

Merged
blove merged 5 commits into
mainfrom
claude/examples-chat-phase-2b-tools-citations
May 9, 2026
Merged

feat(examples-chat): Phase 2B — tool calls + citations#220
blove merged 5 commits into
mainfrom
claude/examples-chat-phase-2b-tools-citations

Conversation

@blove
Copy link
Copy Markdown
Contributor

@blove blove commented May 9, 2026

Summary

Layers tool calls and citations onto the canonical demo by extending the python graph from a single-node generate into a ReAct-style loop with a dedicated tools node and a terminal attach_citations post-process.

  • Python graph: __start__ → generate → [tool_calls?] → tools → generate (loop) or → attach_citations → __end__. Hardcoded 5-document Angular corpus (signals, RxJS interop, control flow, standalone, zoneless) + a search_documents tool. The attach_citations node walks back to the most recent ToolMessage, parses its JSON content, and replaces the final AI message with one carrying additional_kwargs.citations populated (RemoveMessage + AIMessage with same id — standard LangGraph in-place edit pattern).
  • Welcome suggestion: 7th entry "What are Angular signals? (search + cite sources)" exercises both surfaces.
  • CHECKLIST.md: Tool calls + Citations sections populated.

The chat composition's <chat-tool-calls> and <chat-citations> primitives already auto-render — no Angular UI changes needed. The @ngaf/langgraph adapter already populates Message.toolCalls from tool_calls/ToolMessage pairs and Message.citations from additional_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.md
Plan: docs/superpowers/plans/2026-05-08-canonical-chat-demo-phase-2b-tools-citations.md

Phase 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 passed
  • nx run examples-chat-angular:lint — 0 errors
  • nx run examples-chat-angular:build — succeeds (development)
  • Server-side end-to-end probe: submit the Angular-signals welcome prompt with model=gpt-5-mini. Response shows: AI message with 3 tool_calls → 3 ToolMessages with JSON hits → final AI message with additional_kwargs.citations populated with 3 distinct sources (Signals — Angular guide, RxJS interop with signals, Built-in control flow).

Pending visual verification

  • After merge: live smoke against the workspace examples/chat demo. 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.)

blove and others added 5 commits May 8, 2026 19:03
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>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cacheplane Ready Ready Preview, Comment May 9, 2026 2:07am

Request Review

@blove blove merged commit 013ee6b into main May 9, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant