Repository navigation
refactor(loop): remove interim text retry, use system prompt constraint instead - #928
Merged
Merged
Conversation
sorker
pushed a commit
to sorker/nanobot
that referenced
this pull request
Mar 24, 2026
… prompt constraint instead refactor(loop): remove interim text retry, use system prompt constraint instead
WTHDonghai
pushed a commit
to WTHDonghai/nanobot
that referenced
this pull request
Apr 2, 2026
… Jina (HKUDS#928) Add jina-code-embeddings-1.5b and jina-code-embeddings-0.5b to JINA_MODEL_DIMENSIONS so dimension validation works correctly. Add _raise_task_error() helper that catches 422 validation errors mentioning 'task' and produces a user-friendly error message guiding users to set query_param and document_param in their embedding config. Fixes HKUDS#912.
WTHDonghai
pushed a commit
to WTHDonghai/nanobot
that referenced
this pull request
Apr 2, 2026
… Jina (HKUDS#928) Add jina-code-embeddings-1.5b and jina-code-embeddings-0.5b to JINA_MODEL_DIMENSIONS so dimension validation works correctly. Add _raise_task_error() helper that catches 422 validation errors mentioning 'task' and produces a user-friendly error message guiding users to set query_param and document_param in their embedding config. Fixes HKUDS#912.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Remove the interim text retry mechanism (introduced in #825, patched in #887) and replace it with a system prompt constraint.
Problem
PR #825 added a retry mechanism: if the model returns text without tool calls on the first response, the framework retries once, hoping the model will call tools on the second attempt.
This approach had several issues:
interim_content)text_only_retried,interim_content), conditional branching, and acontinuein the agent loop, all for a marginal edge caseSolution
From first principles: the framework should not guess whether the model intended to call tools. If the model returns text, that's its answer.
For models that tend to send preliminary messages ("Let me check") without calling tools, the correct fix is at the prompt level, not the framework level:
This single sentence in the system prompt addresses the root cause without any runtime cost.
Changes
loop.py: Removedtext_only_retried,interim_content, retrycontinue, and fallback logic. The else branch is now just: get content → break. (-15 lines)context.py: Added one-line tool-calling constraint to system prompt. (+1 line)Net effect