Skip to content

fix(llm): resend capped replies; repair the NIM endpoint test - #624

Merged
gloryfromca merged 3 commits into
mainfrom
fix/truncated-reply-retry
Nov 23, 2026
Merged

gloryfromca merged 3 commits into
mainfrom
fix/truncated-reply-retry

Conversation

@Kendrick-Song

Copy link
Copy Markdown
Collaborator

Summary

Resend an LLM reply cut off at the output cap. A generation that runs away until max_tokens (finish_reason length) usually finishes when the identical request is sent again, yet every call failed on the first cut-off: an episode extracted inside /memory/add was lost for good, and a background extraction reran whole.

OpenAIProvider -- EverOS's implementation of the everalgo LLMClient contract, which leaves truncation handling to the implementation (llm-contract.md §3.5) -- now treats length as a resendable attempt with a budget of its own:

  • New truncated_reply_retries (default 1) in [llm], settable per task in [llm.<task>] and in [multimodal]. It applies to every task; no task has a default of its own.
  • Counted apart from invalid_reply_retries, so a runaway generation cannot use up the resend an unparsable reply needs, nor the other way round.
  • A retry never raises max_tokens (§3.1): a reply that is long by nature reaches the cap again and still fails with cut_short.
  • content_filter, refusals and empty replies still fail at once.

Repair the NVIDIA NIM endpoint test (#596). It still called resolve_llm_config, which per-task resolution (#595) replaced, so tests/unit/test_component/test_llm/test_nvidia_endpoint.py failed at collection and make test on main stopped there. It now resolves every task the way the bootstrap does and checks each reaches NIM's base URL, key and model. The #### NVIDIA NIM section of docs/configuration.md had landed under [profile]; it moves back under [llm], unchanged.

Area

  • Architecture method
  • Benchmark
  • Use case
  • Documentation
  • Developer experience
  • CI, build, or release

Verification

Hermetic environment (EVEROS_ROOT in a temp dir, provider keys blank, PYTHON_DOTENV_DISABLED=1):

make lint          # exit 0; import-linter 14 kept, 0 broken
make test          # 4183 passed, 2 skipped
make integration   # 224 passed, 16 skipped, 7 deselected

LoCoMo on this branch (3 full runs, per-task models with deepseek/deepseek-v4.1-flash-1017 for episode and summary; the benchmark config set truncated_reply_retries = 6): 12 replies were cut off at the cap and all 12 completed on the first resend, so the default of 1 would have recovered every one. No episode was lost; all 1540 questions were searched, answered and judged in every run. In an earlier run of the same model without the resend, cut-offs lost 5 of 685 episodes (0.7%).

Checklist

  • I kept the change scoped to the relevant area.
  • I am opening this from a separate branch, not pushing directly to main.
  • I updated docs, examples, or setup notes when behavior changed.
  • I added or updated tests when the change affects behavior.
  • I did not commit secrets, .env files, dependency folders, or generated output.
  • Active relative links in Markdown files resolve.

Notes for Reviewers

  • Scope: the NIM test repair is bundled on purpose -- without it the unit suite on main fails at collection, so this branch could not show a green make test on its own. It is two separate commits.
  • Behavior change: a cut-off reply now costs one more full-budget call before failing, on every task -- the language decision included (worst case two 3s attempts) and the llm_multiround decider (its own [decider] retries multiply with it).
  • Log field: llm_attempt_failed reports retries_left (of the failure's budget; 0 = giving up) in place of attempts.
  • LLMCallError(reason="cut_short") keeps its meaning for callers: content_filter, or length on every attempt the budget allowed.

By submitting this pull request, I agree that my contribution is licensed under
the Apache License 2.0.

🤖 Generated with Claude Code

Kendrick-Song and others added 3 commits November 20, 2026 20:36
A generation that runs away until max_tokens (finish_reason `length`)
usually finishes when the identical request is sent again, yet every
call failed on the first cut-off: an episode inside /memory/add was
lost, a background extraction reran whole.

OpenAIProvider now treats `length` as a resendable attempt, counted by
a new `truncated_reply_retries` (default 1, in [llm], [llm.<task>] and
[multimodal]) apart from `invalid_reply_retries`. A retry never raises
max_tokens (llm-contract 3.1); `content_filter` is still not resent.
The llm_attempt_failed log reports `retries_left` for the failure's
budget in place of `attempts`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test still called resolve_llm_config, which per-task resolution
replaced, so the file failed at collection. It now resolves every task
the way the bootstrap does and checks each one reaches NIM's base URL,
key and model.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It had landed under [profile], past [llm.<task>], as a sub-heading of
the wrong section; it describes an [llm] endpoint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@gloryfromca gloryfromca left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blockers; this can merge as far as I am concerned.

Reviewed the full diff and surrounding LLM provider/configuration code, callers and task-resolution path, branch history, backward-compatible defaults, test intent (including checking that coverage was strengthened rather than weakened), and the repository rules in CLAUDE.md / .claude/rules including architecture constraints. The capped-reply and invalid-reply budgets remain independently bounded, content_filter remains non-resendable, and the unchanged request preserves the configured output cap.

Verification: all project lint gates passed; the targeted LLM/decider suite passed (132 tests). The full unit run reached completion with 4,171 passed, 4 skipped, and 10 pre-existing NLTK tokenizer setup failures because this fresh worktree initially lacked the data installed by make install-deps; after installing the declared punkt_tab and stopwords data, that entire tokenizer file passed (13 tests).

@gloryfromca
gloryfromca merged commit b96fc09 into main Nov 23, 2026
11 checks passed
@gloryfromca
gloryfromca deleted the fix/truncated-reply-retry branch November 23, 2026 02:05
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.

2 participants