Skip to content

fix(agents): use list default_factory for TaskRecorder.input - #279

Open
Ricardo-M-L wants to merge 2 commits into
TencentCloudADP:mainfrom
Ricardo-M-L:fix/plan-parser-and-task-recorder-defaults
Open

fix(agents): use list default_factory for TaskRecorder.input#279
Ricardo-M-L wants to merge 2 commits into
TencentCloudADP:mainfrom
Ricardo-M-L:fix/plan-parser-and-task-recorder-defaults

Conversation

@Ricardo-M-L

Copy link
Copy Markdown

This PR fixes: fix(agents): use list default_factory for TaskRecorder.input

Ricardo-M-L and others added 2 commits April 17, 2026 01:21
When the LLM output does not contain a <plan>[...]</plan> block,
re.search returns None and calling .group(1) raises AttributeError,
which is a confusing way to surface a parser/LLM-format problem.

Raise ValueError with a clear message instead. The preceding <analysis>
block (line 81-82) already uses `if match else ""` - this mirrors that
defensive style. The subsequent assert on line 92 already fails hard
when no tasks are parsed; this gives an equally clear error when the
outer block is missing entirely.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
TaskRecorder.input is annotated as `str | list[TResponseInputItem]`,
but its default_factory is `dict`, so when a TaskRecorder is created
without an explicit input the runtime value is `{}` - neither a str
nor a list. Downstream code in simple_agent.py:264 and chain.py:32
uses the field as either a string message body or a list of input
items, both of which break when given an empty dict.

Other list-typed fields on the same dataclass (`trajectories`,
`raw_run_results`) already use the correct factory; this looks like
a copy-paste slip.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Ricardo-M-L Ricardo-M-L changed the title fix: fix(agents): use list default_factory for TaskRecorder.input fix(agents): use list default_factory for TaskRecorder.input Aug 17, 2026
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.

1 participant