Commit Graph

4 Commits

Author SHA1 Message Date
steve 3f21a676ab fix(agent): recover front-loaded answer past a citations-only terminal
finalOutput already recovered a front-loaded answer when the terminal
(no-tool-call) turn was empty or a short back-reference. But some models
(glm-5.2 via a "cite" tool) front-load the prose answer into an earlier
tool-call turn and close with a terminal turn that is ONLY their sources
("Sources: [pcprice.watch](url) (...), [ebay](url) (...)"). That list is
neither empty nor a back-reference, so it was returned verbatim and the real
answer was discarded (mort issue #1418: the user got a bare sources list; the
good answer was only visible in the trace).

Add isCitationsOnly: a terminal that OPENS with a sources/citations heading,
carries a link, and is dominated by that citation structure (once heading+links
are stripped, little prose remains). Unlike a back-reference the citations are
real content, so finalOutput recovers the prior substantive answer and APPENDS
the citations below it (deduped). The dominance check keeps a real prose answer
that merely opens with "Source: ... http://..." from being misclassified; the ^
anchor keeps an answer that ends with a Sources section from matching; the
citations branch is decoupled from the terminal-length ratio so a CONCISE
front-loaded answer is still recovered; and preambleRe now applies regardless of
length so planning narration is never recovered. Healthy terminal answers are
unchanged; zero extra model calls.

Tests: TestIsCitationsOnly (19 cases incl. bold/ATX/backref/prose negatives),
new TestFinalOutput cases (concise+long-citations, source-led-not-hijacked,
long-preamble-skipped, dedup), and end-to-end
TestRun_RecoversFrontLoadedAnswerWithCitations. Full agent suite green (-race).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-10 15:16:46 +00:00
steve 1fd7109a42 fix(agent): recover front-loaded answer when terminal turn is degenerate
CI / Tidy (pull_request) Successful in 9m31s
CI / Build & Test (pull_request) Successful in 10m14s
CI / Tidy (push) Successful in 9m26s
CI / Build & Test (push) Successful in 10m19s
The agent loop took the final answer only from the terminal (no-tool-call)
turn. Models that "front-load" their answer into an earlier turn that also
calls a tool — then close with a trivial pointer like "(Already answered
above.)" — had their real answer discarded and the pointer delivered. This
recurs across several open-weight models (glm-5.2, etc.); well-behaved models
(Claude/GPT) defer their answer to the terminal turn and are unaffected.

finalOutput() now falls back to the last substantive assistant content in the
transcript when the terminal text is weak (empty, or a short back-reference).
The predicate is narrow and back-reference-gated so short-but-correct answers
("42", "It's down, restarting now.") are never overridden; recovery only picks
a prior turn that reads like a real answer, not a preamble. Zero extra model
calls. Terminal-answer behavior for normal runs is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 18:37:38 -04:00
steve 0147a79d18 feat: conversion-driven extensions — resolvers, DefineTool, hooks, ops controls
CI / Tidy (push) Successful in 9m31s
CI / Build & Test (push) Successful in 10m13s
Phase 9a (ADR-0014): Registry.RegisterResolver for dynamic tiers;
DefineTool[Args] typed tools; Usage cache/reasoning detail fields wired
through anthropic/openai/google; WithPromptCaching (Anthropic
cache_control); agent supervision hooks (WithMaxStepsFunc, WithSteer,
WithCompactor, WithToolErrorLimits + ErrToolLoop); health
Bench/Unbench/Snapshot; ChainConfig.Observer failover events.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 13:30:06 +02:00
steve 7dab4112ff feat: agent run loop, Generate[T], reflect-derived schemas
Phase 5:
- agent/: model + system prompt + toolboxes composition; bounded
  tool-dispatch loop (default 10 steps); panic-proof tool execution;
  unknown-tool and duplicate-name handling; history continuation; step
  observers; partial results on ErrMaxSteps/errors (ADR-0012)
- llm.SchemaFor[T]: strict-compatible JSON schemas from Go types
  (nullable pointers, description/enum tags, recursion rejected)
- majordomo.Generate[T]: typed structured output with fence-stripping
  decode and model-naming errors
- README agents/structured-output sections + matrix synced

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 13:10:18 +02:00