Skip to content

feat: end research with complete_research when a finalizer writes the answer - #173

Merged
devhims merged 1 commit into
mainfrom
feat/research-complete-signal
Oct 9, 2026
Merged

devhims merged 1 commit into
mainfrom
feat/research-complete-signal

Conversation

@devhims

@devhims devhims commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Problem

With a finalizer configured (always, in production), research's finalize_answer never saves its answer: phaseContext.finalize throws the finalization handoff by design, and the finalizer writes the published answer. Research still had to compose the full answer as tool arguments first. Over the last 14 days, 127 of 250 completed runs paid for that discarded answer. In run f515c361 it cost 1,332 output tokens and 7.7 s before the finalizer started.

What changed

  • When a finalizer is configured, research is offered complete_research instead of finalize_answer. It takes no input, stops the loop, and hands off through the existing finalization path (agent_finalization_handoff with reason: research_complete).
  • The capability prompts for inspect_video and topic_research tell research to call complete_research and not to write the answer. Without a finalizer, the prompts and finalize_answer are unchanged.
  • The visual-evidence gate now withholds whichever completion tool the run uses.
  • A stray finalize_answer call (for example one copied from conversation history) hands off the same way, unless completion is currently withheld. Its answer is never used.

Testing

  • npx tsc --noEmit
  • npx vitest run: 1599 passed. New: a single-video run where research calls complete_research, the finalizer writes the answer, and research is never offered finalize_answer; complete_research stays withheld until required visual work finishes.
  • vitest.user-account.config.ts: 349 passed. vitest.auth.config.ts: 39 passed.
  • Live, opt-in AGENT_COMPLETION_LIVE=1 npx vitest run test/research-completion.live.test.ts against Fireworks GLM: research called complete_research on its first step, using 19 output tokens in 2.7 s, then the finalizer produced a validated answer.

… answer

With a finalizer configured, research previously composed a full answer
in finalize_answer arguments, which was always discarded at the handoff.
Research is now offered complete_research instead. It takes no input,
ends the loop, and hands off to the finalizer through the existing path.
A stray finalize_answer call hands off the same way unless required
visual work still withholds completion. Without a finalizer, research
keeps finalize_answer.
@vercel

vercel Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
video2ctx-web Ready Ready Preview Oct 9, 2026 9:38am UTC

@devhims
devhims merged commit e25938c into main Oct 9, 2026
10 checks passed
@devhims
devhims deleted the feat/research-complete-signal branch October 9, 2026 09:41
devhims added a commit that referenced this pull request Oct 9, 2026
Since #173, research with a configured finalizer ends by calling
complete_research; finalize_answer is no longer offered. The context
gathering tests still simulated finalize_answer and passed through an
unknown-tool path. They now use complete_research, the production path.

This branch was successfully deployed

1 active deployment
Preview — c415116a Deployed Oct 9, 2026 by vercel[bot]
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