fix(agents): guard missing plan block and correct TaskRecorder default#268
Open
wustwyh wants to merge 1 commit into
Open
fix(agents): guard missing plan block and correct TaskRecorder default#268wustwyh wants to merge 1 commit into
wustwyh wants to merge 1 commit into
Conversation
- ChainPlanner._parse now handles a missing <plan>...</plan> block gracefully instead of raising AttributeError on None.group(). - TaskRecorder.input default_factory changed from dict to list to match its str | list[TResponseInputItem] annotation. Fixes TencentCloudADP#261.
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
Fixes #261.
This PR addresses two small defensive-coding issues in
utu/agents/.Changes
1.
ChainPlanner._parseno longer crashes on a missing<plan>blockFile:
utu/agents/orchestrator/chain.pyThe
<analysis>match was already guarded withif match else "", but the<plan>match immediately called.group(1)without checking forNone. When the LLM returns malformed/truncated output that omits the plan block, this raised:Now the plan match is guarded the same way as the analysis match. The existing
assert len(tasks) > 0, "No tasks parsed from plan"still produces a clear error for the empty-plan case.2.
TaskRecorder.inputdefault matches its annotationFile:
utu/agents/common.pyTaskRecorder.inputis annotated asstr | list[TResponseInputItem], but itsdefault_factorywasdict, so a default instance gotinput = {}. This change aligns it with the other list-typed fields on the same dataclass by usingdefault_factory=list.Tests
Added
tests/agents/test_issue_261.pycovering:<plan>block raisesAssertionError(notAttributeError).TaskRecorder()defaultsinputto an empty list.All three tests pass.