OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Bug]: llm-wiki compile of large single sources (books, long reports) always ends COMPILE_INCOMPLETE; agent never emits a valid result

Open coonsemmett opened this issue 1 month ago • 4 comments

Issue Origin

Observed or reproduced in a real environment

Bug Description

Incremental ov compile with the llm-wiki skill works for small sources (articles, short government documents, 5-50 KB) but fails every time on large single sources: book-length PDFs (≈300 pages) and long reports (100+ pages). The run reads hundreds of thousands to ~2M input tokens and then ends COMPILE_INCOMPLETE with no pages written. The child agent never submits an emit result that passes validation. We saw four different validation failures across runs:

  1. Required agent transform ended without validated output: No emit result was submitted (most common)
  2. result_ref is an alternative to all inline result fields: the agent sends result_ref and a non-empty inline files list in the same emit call
  3. Unsafe relative path rejected: '': the agent emits an empty path
  4. Final review incomplete; publishing original artifacts: ... Missing staged outputs; restore them or report unresolved files, followed by No output was acknowledged.

The failure doesn't depend on model strength, and splitting the source into smaller pieces doesn't avoid it (see Additional Context).

Steps to Reproduce

  1. ov add-resource <book.pdf> -p viking://resources/src/books (≈300-page book with a text layer; import succeeds)
  2. Have an existing wiki target, e.g. one already compiled from a few small sources.
  3. ov compile --from viking://resources/src/books/<book> --to viking://resources/wiki --skill viking://user/default/skills/llm-wiki --instruction "<short instruction asking for entity pages and cited claims>"
  4. Poll ov task status <cmp-id> until it ends.

Expected Behavior

The compile finishes and creates or updates wiki pages, as it does for small sources. If a source is too large, it fails early with a clear "source too large" error instead of running through ~0.5–2M tokens first.

Actual Behavior

The task ends failed with COMPILE_INCOMPLETE: No accepted final artifacts remain after failed jobs (or No output was acknowledged.). meta.pipeline.errors shows one of the four messages above. No pages are created or updated. Typical token use per failed run: 0.44M–1.9M input, 5k–53k output.

Error Logs

"pipeline": {
  "errors": [
    "1 pipeline jobs failed: ['Required agent transform ended without validated output: result_ref is an alternative to all inline result fields (also sent: files)']",
    "No accepted final artifacts remain after failed jobs"
  ],
  "tokens": { "cached": 0, "input": 970610, "output": 53437 }
}
"1 pipeline jobs failed: ['Required agent transform ended without validated output: No emit result was submitted']"   (input 350869)
"13 pipeline jobs failed: ['Required agent transform ended without validated output: No emit result was submitted', ...]"   (input 1942718)
"1 pipeline jobs failed: [\"Required agent transform ended without validated output: Unsafe relative path rejected: ''\"]"   (input 260567)
"Final review incomplete; publishing original artifacts: Required agent transform ended without validated output: Missing staged outputs; restore them or report unresolved files"   (task error: COMPILE_INCOMPLETE: No output was acknowledged.)

OpenViking Version

0.5.2 (pip), openviking-sdk 0.1.17

Python Version

3.13.15

Operating System

Windows

Model Backend

OpenAI (provider openai-codex, ChatGPT login)

Additional Context

  • Model: vlm.model = gpt-6-luna, reasoning_effort: low. A test with gpt-6.1-sol on the same book failed the same way (result_ref + files, 970k input tokens), so it doesn't look like a model-skill problem.
  • Splitting doesn't help: I split one book into 10 chapter Markdown files (20–100 KB each) and imported each as its own resource. Chapters 0–4 all failed (No emit result was submitted ×4, result_ref + files ×1), each still reading 0.44M–1.9M input tokens. Short primary-source documents of similar size compile fine, so the size of the source alone doesn't seem to be the trigger.
  • What did succeed in the same wiki: about 12 small sources (journal articles, declassified cables, short government reports), each creating 1–5 pages.
  • Local change, disclosed: to work around case 2, I patched vikingbot/compile/pipeline_agent.py locally so that fields sent next to result_ref are dropped only when empty (None, "", [], {}); non-empty fields still raise the error, with the field names appended (that's where "(also sent: files)" comes from). That patch made one ~2 MB report compile; it doesn't affect cases 1, 3 and 4. All other code is stock 0.5.2.
  • Possible cause: EmitResult.parameters offers result_ref as an alternative to the full inline schema, while the agent instructions also say to "emit content_ref paths" inside files for large outputs. The model seems to mix the two submission styles, which the validator rejects on every retry.
  • Cost of failing late: each failed run spends a large share of the user's model quota before failing.
  • Related but distinct: #6368 (shuffle embedding batches), #6795 (first full build registers few slices).

coonsemmett avatar Oct 30 '26 18:10 coonsemmett

Hi, I looked at this on current main (2f6871a, after #6884 and #6887) and want to confirm my understanding before proposing anything.

What I could reproduce without a model: calling EmitResult.execute from bot/vikingbot/compile/pipeline_agent.py directly, with a fake sandbox and FileResponse.

  • {"result_ref": "r.json", "files": [<non-empty>]} is rejected with "result_ref is an alternative to all inline result fields" (your case 2). The same call with files: [] is rejected too, so your local "drop empty siblings" patch is not upstream.
  • {"result_ref": "r.json"} alone is accepted.
  • Repeating the same mixed call hits retry_allowed after 3 identical errors, and the child ends with "Required agent transform ended without validated output".
  • The emit schema marks nothing as required and offers both result_ref and the inline fields. The agent instructions also say both "emit content_ref paths in files" and "emit only result_ref", and the rejected-mixed-call path does not get the "Repair rejected-*.json" hint.

What I could not reproduce: case 1 ("No emit result was submitted"), which seems to be the dominant failure and the one that burns the tokens. It needs a real model and a large source. I have not tested it on current main. Case 4 involved the final-review agent, which #6887 appears to have removed. For case 3, an empty inline path passes EmitResult and fails later, so it looks like a separate feedback-timing issue.

So I would scope any change narrowly to the result_ref plus sibling-fields contract, and not claim it fixes the large-document failure.

Which contract would you prefer?

  1. Keep strict rejection, but name the extra fields in the error and give the same repair hint as for other rejected calls.
  2. Tolerate only empty siblings next to result_ref (None, "", [], {}) and still reject non-empty ones. This is lossless but would not help the non-empty files case in your logs.
  3. Change the schema or prompt so the two styles are mutually exclusive. I would not silently ignore non-empty inline fields, since that discards model output.

If one of these fits, I can send a small PR (under 100 lines, with a deterministic unit test) after you confirm. I am happy to leave case 1 and the "fail early on oversized sources" question to you or a separate issue.

PoisonGodv avatar Nov 02 '26 09:11 PoisonGodv

One more data point on the result_ref contract discussed above. It is the reverse of case 2, and it bears on the choice between the options @PoisonGodv listed.

Versions: OpenViking 0.5.3, with bot/vikingbot/compile from main 4b92b3065. LiteLLM 1.102.4. Model gpt-6.1-terra on the OpenAI Responses API. The emit handling in pipeline_agent.py is unchanged on current main (3fab17054).

Workload: the knowledge-graph skill, a directory compile with 25 to 45 transcript files per batch. The failures happen in the Reduce agent.

Observed: the model fills in every property of the emit schema. Nothing is marked required, so it sends result_ref: "" next to a complete, valid inline result. EmitResult.execute treats the presence of a result_ref key as a file submission:

  • With inline fields present, the call fails at len(kwargs) != 1 with "result_ref is an alternative to all inline result fields".
  • When only the empty result_ref gets through, validate_relative_file_path("") fails with "Unsafe relative path rejected: ''". This is a second source of case 3 in the original report, separate from an empty inline path.

After three identical rejections, retry_allowed stops the job with "Required agent transform ended without validated output", and the whole batch fails. The inline result was valid every time.

Expected: an empty or null result_ref counts as absent, and the inline result is validated as usual.

Why schema or prompt changes alone may not be enough (option 3): the compile tools are sent without strict mode, so the provider does not enforce the schema. An anyOf or oneOf split would be a hint to the model, not a guarantee, and a model that fills every listed property can still add the empty field.

Workaround we run (a local patch to EmitResult.execute). Since applying it, every Reduce call has emitted successfully:

if isinstance(kwargs, dict) and kwargs.get("result_ref") in (None, ""):
    kwargs.pop("result_ref", None)
if isinstance(kwargs, dict) and "result_ref" in kwargs:
    ...
    # removed: if len(kwargs) != 1: raise ValueError("result_ref is an alternative ...")
    relative = validate_relative_file_path(kwargs["result_ref"])

The second half of our patch lets a non-empty result_ref win over inline fields, because the tool description already defines the referenced file as the complete emit arguments. That is the "silently ignore" behavior @PoisonGodv would rather avoid, and we do not depend on it. The empty-result_ref line alone fixes our failure.

Ask: whichever contract you choose for sibling fields, please treat an empty or null result_ref as absent before the alternative check. This is the mirror image of option 2 (tolerate empty siblings). It loses no data, and a small deterministic unit test would cover it: {"result_ref": "", <valid inline fields>} should be accepted as an inline emit. We are happy to open that PR if it helps.

ragnos-dev avatar Nov 09 '26 16:11 ragnos-dev

Thanks for the clear reproduction and for separating this from the non-empty sibling-field case. If you're still interested, feel free to open the narrow PR for treating an empty ("") or null result_ref as absent and passing the remaining inline fields through the existing validation. I won't prepare a competing PR and would be happy to help test or review. The broader contract for a non-empty result_ref alongside inline fields remains for the maintainers to decide.

PoisonGodv avatar Nov 12 '26 06:11 PoisonGodv

Hi! Compile now has a simple mode that’s enabled by default. You can pull the latest changes from main to try it out. This version is much more stable and uses significantly fewer tokens.

fujiajie666 avatar Nov 16 '26 09:11 fujiajie666