Repository navigation
Ground cleaned-up quotes; add a TypeScript tool-calling diagram agent - #4
Conversation
…g an article
"Attention Is All You Need" shipped with two concepts and no visuals. The
free model quoted the paper with its LaTeX tidied ("dimension d_k" for
"dimension $d_k$", curly quotes, citations dropped), and grounding only
accepted exact or whitespace-collapsed matches, so most quotes were dropped.
Every opportunity whose concept was among them then went too, unless another
grounded concept shared its section.
- span_for_text falls back to matching a normalised view (TeX commands and
citations removed, quotes and dashes folded, case-insensitive) mapped back
to exact raw offsets, so a span still points at real text of the paper. A
partly copied quote grounds to its longest verbatim run when that run is at
least 8 words and 60% of the quote; anything less still fails.
- A quote not found in its cited section is searched for in the others; the
attribution is corrected, the text is unchanged.
- A grounded opportunity whose concept did not ground creates that concept
from its own claim and span instead of being dropped.
- PIPELINE_VERSION -> 0.3.1-grounding, so the two weak cached articles are
rebuilt.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BgiEmhLGtyG2FWJkiiwD1M
reader/app/api/diagram is a small agent harness in the reader's Next.js app (server-side; the key never reaches a browser). A model draws a concept_diagram by calling three tools, each checked as it is called: - draw sets every element and arrow, and answers with problems: unknown ids, two elements in one cell, self-loops, duplicate arrows; - script sets every step, and answers with unknown ids, marks on elements without items, and runtime over 70s, measured with planConceptDiagram, the code that animates the scene in the browser; - finish submits, refused with reasons while problems remain. The prompt asks for draw and script in the first turn, so a diagram usually takes two turns; a problem costs one more turn in the same conversation instead of a full regeneration. reasoning_details is passed back between turns. Each call has its own timeout (90s) inside the overall deadline, so a slow, spent or withdrawn free model hands over to the next model with time left for it to answer. The route refuses every request without ARCVISUAL_INTERNAL_SECRET. The Python pipeline asks the agent for a concept diagram's first attempt when ARCVISUAL_DIAGRAM_AGENT_URL and ARCVISUAL_INTERNAL_SECRET are set, passing the remaining step budget, and validates the result exactly as it does one-shot output. Not configured, unreachable, out of time or no accepted diagram: it falls back to one-shot generation. Tests: 17 vitest cases for the tools, loop and client (npm test, now in CI); 8 pytest cases for the Python seam. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BgiEmhLGtyG2FWJkiiwD1M
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 79b3c66c1b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| beats = fit_beats(captions, MIN_BEAT_S * 2 * len(captions)) | ||
| note = f"drawn by the diagram agent in {drawn.turns} turn(s) on {drawn.model}" | ||
| # Tokens were spent by the agent's own calls, which report no price. | ||
| return drawn.params, beats, False, Usage(attributed=False), [note, *drawn.notes] |
There was a problem hiding this comment.
Include paid agent calls in the scene budget
When the default free endpoint is exhausted or times out, the agent can fall through to paid models, but this reports zero cost and discards the token usage returned by the route. build_scene adds GenerateResult.cost_usd to its spend before checking the per-scene ceiling, so these paid turns are invisible to both the ceiling and the job total. Price the agent usage or prevent unpriced paid fallbacks.
Useful? React with 👍 / 👎.
| caption: { type: "string", description: "One plain sentence, under 90 characters." }, | ||
| show: { type: "array", items: { type: "string" } }, | ||
| focus: { type: "array", items: { type: "string" } }, | ||
| flow: { type: "array", items: { type: "string" }, description: "A path of element ids, in order." }, |
There was a problem hiding this comment.
Enforce the template's eight-stop flow limit
If the model emits a flow with more than eight IDs, this tool schema accepts it and checkScript checks references and runtime but not flow length; finish can therefore accept a result that arcvisual/templates/concept_diagram.py rejects because Step.flow is limited to eight items. Codegen then spends a failed first attempt and retries via one-shot generation. Add the matching limit to the tool schema or checker.
Useful? React with 👍 / 👎.
A live run against the free Nemotron endpoint with separate draw / script / finish tools produced a good diagram but used all five turns (75s): the model called the tools one at a time, and each turn costs ~15s there. One tool now takes the whole diagram and is accepted the moment it has no problems, listing every problem at once otherwise, so the good case is one turn and each fix one more. Turn cap 5 -> 4. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BgiEmhLGtyG2FWJkiiwD1M
1. Grounding: articles were coming out empty (
06e31f9)"Attention Is All You Need" shipped with 2 concepts and 0 visuals.
dimension $d_k$, with straightened quotes and citations dropped). Grounding accepted only exact or whitespace-collapsed matches, so most quotes were dropped.What changes:
span_for_textnow falls back to a normalised comparison: TeX commands and citations removed, quotes and dashes folded, case ignored. Matches are mapped back to exact raw offsets, so a span still points at real characters of the paper.PIPELINE_VERSIONis now0.3.1-grounding, so the two weak cached articles are rebuilt.2. TypeScript diagram agent (
79b3c66)reader/app/api/diagramis an agent harness in the reader's Next.js app. It runs server-side, so the key never reaches a browser. A model draws aconcept_diagramby calling three tools, each checked as it is called:drawscriptplanConceptDiagram, the browser's own animation code)finishdrawandscripttogether, so a diagram is usually 2 turns. A problem costs one more turn in the same conversation, not a full regeneration.reasoning_detailsis passed back between turns.ARCVISUAL_INTERNAL_SECRET.ARCVISUAL_DIAGRAM_AGENT_URLandARCVISUAL_INTERNAL_SECRETare set, and validates the result the same way as one-shot output. Any failure falls back to one-shot generation.Verification
pytestpasses (11 new grounding tests, 8 new agent tests).ruffis clean.npm test(17 vitest cases, now in CI),tsc --noEmitandnext buildpass.reasoning_details: adrawturn took 16 s and afinishturn 0.4 s.Deploying (not done yet)
ARCVISUAL_INTERNAL_SECRETandOPENROUTER_API_KEY.ARCVISUAL_DIAGRAM_AGENT_URL=https://arcvisual.vercel.app/api/diagram.Generated by Claude Code