fix: surface prompt template eval errors, fail-safe async_safety fallback, and set _parent_agent_var in sync wrapper - #72
Open
Eros483 wants to merge 1 commit into
Conversation
…back, and set _parent_agent_var in sync wrapper Signed-off-by: Eros483 <arnabmandal2912@gmail.com>
Author
|
Hi @alessiodevoto . What's up? |
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.
What does this PR do?
Three defensive fixes targeting silently swallowed errors and a sync-wrapper
parity gap:
agent.py —
Agent._resolve_docstring_template()catcheseval()failures with a bare
except Exception:and silently falls back to raw{placeholder}text. If a user has a typo in{self.attr}, the brokenexpression ships in the prompt with zero feedback. Added
logger.debug(..., exc_info=True)inside the except block so templateerrors are visible at debug level.
async_safety.py —
_is_event_loop_thread()returnsTruewhen itcannot determine the thread (missing
_thread_idattribute). This isfail-dangerous: it would block legitimate cross-thread
Future.result()calls. Changed fallback to
Falseso calls are allowed through when wecan't verify.
method_wrapper.py —
create_sync_agent_method_wrappernever calls_parent_agent_var.set(self), unlike its async counterpart (line 183).Subagents instantiated inside a sync method cannot inherit the parent's
LLM. Added
parent_token = _parent_agent_var.set(self)after thecall-id push and
_parent_agent_var.reset(parent_token)infinally,mirroring the async wrapper.
Related issues
N/A
Checklist
uv run ruff check .anduv run ruff format --check .pass)uv run pytest)Checklist notes
(debug logging, boolean flip, contextvar parity with existing async path).
Existing test suite covers all modified code paths.