chore(sdk): update unset logic - #2435
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR adjusts the deprecated files_update handling in backend result types so callers never observe the sentinel value and files_update is normalized to dict | None.
Changes:
- Introduces an
Unsetsentinel and_normalize_files_update()helper to convert the sentinel intoNoneand emit the deprecation warning only whenfiles_updateis explicitly provided. - Reworks
WriteResultandEditResultto use@dataclass(init=False)with custom__init__, ensuringfiles_updateis stored asdict | None(never_Unset).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| error: str | None | ||
| path: str | None | ||
| files_update: dict[str, Any] | None | ||
|
|
There was a problem hiding this comment.
files_update used to be excluded from the dataclass repr (it was declared with repr=False). With the new @dataclass(init=False) + plain annotation, files_update will now appear in WriteResult.__repr__, which can make logs noisy and potentially include large/sensitive data even though the field is deprecated. Consider restoring repr=False for files_update (e.g., by using a dataclass field with repr=False, while still normalizing the value in __init__).
| class _Unset: | ||
| """Sentinel type for detecting explicit parameter usage.""" | ||
|
|
||
|
|
||
| _FILES_UPDATE_UNSET = _Unset() | ||
| Unset = _Unset() | ||
|
|
There was a problem hiding this comment.
The sentinel is now exposed as a public module symbol named Unset. This is a new public API surface and the CamelCase name is easy to confuse with a type/class. If external callers aren’t expected to use it, consider keeping it private (e.g., _UNSET) or, if it is meant to be a constant, use an all-caps name to match typical constant conventions.
Update unset logic so that files_update can only be dict | None (not Unset)
Merges upstream-sync-round11 into master. Key upstream changes: - fix: remove legacy subagents API (langchain-ai#2443) — backward-compat shim retained - fix: inherit parent interrupt_on for subagents (langchain-ai#2334) - fix: plumb through generics for create_deep_agent (langchain-ai#2383) - fix: improvements in sandbox.write/read (langchain-ai#2321) - fix(acp): block dangerous shell patterns (langchain-ai#2308) - chore: update unset logic (langchain-ai#2435) - feat(evals): auto-regenerate eval catalog (langchain-ai#2432) - Various evals CI improvements, deps bumps (aiohttp, anthropic, litellm) Local fixes: - Restore local enhancements (logging, stream_writer, skills_allowlist, _EXCLUDED_STATE_KEYS expansion) - Manual langchain>=1.2.15 dependency extraction (version kept at 0.5.0) - Regenerate EVAL_CATALOG.md Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> # Conflicts: # libs/acp/deepagents_acp/server.py # libs/acp/uv.lock # libs/deepagents/deepagents/middleware/subagents.py
Update unset logic so that files_update can only be dict | None (not Unset)
Update unset logic so that files_update can only be dict | None (not Unset)