Skip to content

fix: plumb through generics for create_deep_agent - #2383

Merged
Sydney Runkle (sydney-runkle) merged 4 commits into
mainfrom
sr/fix-typing
Apr 1, 2026
Merged

fix: plumb through generics for create_deep_agent#2383
Sydney Runkle (sydney-runkle) merged 4 commits into
mainfrom
sr/fix-typing

Conversation

@sydney-runkle

Copy link
Copy Markdown
Collaborator

building off of #1779
will assign co-author credit to pawel-twardziak, thank you!!

@github-actions github-actions Bot added deepagents Related to the `deepagents` SDK / agent harness feature New feature/enhancement or request for one internal User is a member of the `langchain-ai` GitHub organization size: XS < 50 LOC labels Apr 1, 2026
@codspeed-hq

codspeed-hq Bot commented Apr 1, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 32 untouched benchmarks
⏩ 15 skipped benchmarks1


Comparing sr/fix-typing (22b79a2) with main (f46a730)

Open in CodSpeed

Footnotes

  1. 15 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

name: str | None = None,
cache: BaseCache | None = None,
) -> CompiledStateGraph:
) -> CompiledStateGraph[AgentState[ResponseT], ContextT, _InputAgentState, _OutputAgentState[ResponseT]]: # ty: ignore[invalid-type-arguments] # ty can't verify generic TypedDicts satisfy StateLike bound

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably remove these hacks in LG, they don't type check well, the bound doesn't make that much sense

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also context should probably default to Any, but alas here we are

@sydney-runkle Sydney Runkle (sydney-runkle) changed the title feat: plumb through generics for create_deep_agent fix: plumb through generics for create_deep_agent Apr 1, 2026
@github-actions github-actions Bot added fix A bug fix (PATCH) and removed feature New feature/enhancement or request for one labels Apr 1, 2026
Co-Authored-By: Pawel Twardziak <pawel-twardziak@users.noreply.github.com>
@sydney-runkle
Sydney Runkle (sydney-runkle) merged commit 6c28e22 into main Apr 1, 2026
27 checks passed
@sydney-runkle
Sydney Runkle (sydney-runkle) deleted the sr/fix-typing branch April 1, 2026 14:40
james8814 pushed a commit to james8814/deepagents that referenced this pull request May 1, 2026
building off of langchain-ai#1779
will assign co-author credit to @pawel-twardziak, thank you!!

---------

Co-authored-by: Pawel Twardziak <pawel-twardziak@users.noreply.github.com>
james8814 pushed a commit to james8814/deepagents that referenced this pull request May 1, 2026
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
Mason Daugherty (mdrxy) added a commit that referenced this pull request Jul 7, 2026
)

Closes #4051

---

`create_deep_agent` declared its `middleware` parameter as a bare
`Sequence[AgentMiddleware]`. That pins `ContextT` to `None`, so type
checkers reject context-aware middleware such as
`AgentMiddleware[AgentState, Context]` even when a matching
`context_schema` is passed.

PR #2383 threaded `ContextT` through `context_schema` and the return
type but missed `middleware`. This types it as
`Sequence[AgentMiddleware[StateT_co, ContextT]]`, mirroring upstream
`langchain.agents.create_agent`, so the inferred context type is
preserved. `StateT_co` is imported from
`langchain.agents.middleware.types`.

A type-level regression test runs `ty` over a fixture that passes a
context-aware middleware alongside `context_schema`; it fails against
the previous bare annotation.

Made by [Open
SWE](https://openswe.vercel.app/agents/305e0718-361a-e13b-6940-8cb55cb29dee)

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
Marcelo5444 pushed a commit to Marcelo5444/deepagents that referenced this pull request Jul 30, 2026
building off of langchain-ai#1779
will assign co-author credit to @pawel-twardziak, thank you!!

---------

Co-authored-by: Pawel Twardziak <pawel-twardziak@users.noreply.github.com>
Marcelo5444 pushed a commit to Marcelo5444/deepagents that referenced this pull request Jul 30, 2026
…ngchain-ai#4055)

Closes langchain-ai#4051

---

`create_deep_agent` declared its `middleware` parameter as a bare
`Sequence[AgentMiddleware]`. That pins `ContextT` to `None`, so type
checkers reject context-aware middleware such as
`AgentMiddleware[AgentState, Context]` even when a matching
`context_schema` is passed.

PR langchain-ai#2383 threaded `ContextT` through `context_schema` and the return
type but missed `middleware`. This types it as
`Sequence[AgentMiddleware[StateT_co, ContextT]]`, mirroring upstream
`langchain.agents.create_agent`, so the inferred context type is
preserved. `StateT_co` is imported from
`langchain.agents.middleware.types`.

A type-level regression test runs `ty` over a fixture that passes a
context-aware middleware alongside `context_schema`; it fails against
the previous bare annotation.

Made by [Open
SWE](https://openswe.vercel.app/agents/305e0718-361a-e13b-6940-8cb55cb29dee)

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepagents Related to the `deepagents` SDK / agent harness fix A bug fix (PATCH) internal User is a member of the `langchain-ai` GitHub organization size: XS < 50 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants