fix(agents): harden update_agent null-like args#3237
Open
Eilen6316 wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Hardens the update_agent builtin tool against LLM-provided “null-like” placeholder strings so optional fields behave as omitted, avoiding accidental persistence of "null"/"none"/"undefined" and reducing repeated tool-call failure loops during agent self-updates.
Changes:
- Added Pydantic
BeforeValidator-based normalization to treat null-like strings asNonefor optional text and optional list fields inupdate_agent. - Ensured
update_agentreturns errorToolMessages withstatus="error"for validation-style failures (e.g., no fields provided). - Updated the lead-agent self-update prompt and expanded tests to exercise the
.invoke()path and null-like inputs.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| backend/packages/harness/deerflow/tools/builtins/update_agent_tool.py | Adds null-like string normalization via validators and marks validation failures with ToolMessage(status="error"). |
| backend/packages/harness/deerflow/agents/lead_agent/prompt.py | Clarifies self-update instructions to omit unchanged fields and not pass null-like placeholders. |
| backend/tests/test_update_agent_tool.py | Adds .invoke()-based regression tests for null-like placeholders and list-field strictness behavior. |
| backend/tests/test_lead_agent_prompt.py | Verifies the self-update prompt includes guidance about null-like placeholder strings. |
Comment on lines
100
to
106
| Pass ``soul`` as the FULL replacement SOUL.md content — there is no patch | ||
| semantics, so always start from the current SOUL and apply your edits. | ||
|
|
||
| Pass ``skills=[]`` to disable all skills for this agent. Omit ``skills`` | ||
| entirely to keep the existing whitelist. | ||
| entirely to keep the existing whitelist. Do not pass literal strings like | ||
| ``"null"`` / ``"none"`` for unchanged fields; omit those fields instead. | ||
|
|
|
|
||
| if soul is None and description is None and skills is None and tool_groups is None and model is None: | ||
| return _err("No fields provided. Pass at least one of: soul, description, skills, tool_groups, model.") | ||
| return _err('No fields provided. Pass at least one of: soul, description, skills, tool_groups, model. Omit unchanged fields instead of passing null-like strings such as "null" or "none".') |
Contributor
Author
There was a problem hiding this comment.
I added undefined to both the docstring guidance and the validation error message so they match the null-like normalization behavior.
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
Supersedes #2945.
Closes #2906.
This reopens the update_agent null-like argument fix on a fresh PR so it appears with the latest PR queue. The branch is based on the latest
main.Changes
"null","none","undefined") for optionalupdate_agentfields so they behave like omitted fields.skills/tool_groupsschema strict as arrays while accepting null-like placeholders as omitted through the production.invoke()path.update_agentvalidation failures as errorToolMessages.Review follow-up from #2945
BeforeValidatoras the single production normalization path..invoke()consistently.Tests
uv run pytest tests/test_update_agent_tool.py tests/test_update_agent_e2e_user_isolation.py tests/test_lead_agent_prompt.py::test_build_self_update_section_present_for_custom_agent tests/test_tool_args_schema_no_pydantic_warning.pyuvx ruff check .uvx ruff format --check .