repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
deepagents | libs/deepagents/deepagents/_version.py | .py | """Version information for `deepagents` (SDK)."""
from __future__ import annotations
import json
import logging
from functools import cache
from importlib.metadata import Distribution, distributions
from pathlib import Path
from urllib.parse import urlparse
from urllib.request import url2pathname
from packaging.vers... | 218 | 9,350 |
deepagents | libs/deepagents/deepagents/__init__.py | .py | """Deep Agents package."""
from deepagents._version import __version__
from deepagents.graph import (
DeepAgentState,
create_deep_agent,
)
from deepagents.middleware.async_subagents import AsyncSubAgent, AsyncSubAgentMiddleware
from deepagents.middleware.filesystem import FilesystemMiddleware, FilesystemPermis... | 49 | 1,344 |
deepagents | libs/deepagents/deepagents/_excluded_middleware.py | .py | """Filtering helpers for `HarnessProfile.excluded_middleware`.
These functions validate, apply, and audit exclusions against assembled
middleware stacks. The set of *required scaffolding* — classes/names that
must remain in the stack for the agent to function — is owned by
`deepagents.graph` and threaded through as pa... | 226 | 9,497 |
deepagents | libs/deepagents/deepagents/_models.py | .py | """Shared helpers for resolving and inspecting chat models."""
from __future__ import annotations
import logging
from collections.abc import Mapping
from langchain.chat_models import init_chat_model
from langchain_core.language_models import BaseChatModel
from deepagents.profiles.provider.provider_profiles import a... | 212 | 8,358 |
deepagents | libs/deepagents/deepagents/_tools.py | .py | """Helpers for inspecting and rewriting `create_deep_agent` tool inputs."""
from __future__ import annotations
from typing import TYPE_CHECKING, Any, cast
from langchain_core.tools import BaseTool
if TYPE_CHECKING:
from collections.abc import Callable, Mapping, Sequence
def _tool_name(tool: BaseTool | Callabl... | 66 | 2,235 |
deepagents | libs/deepagents/deepagents/graph.py | .py | """Primary graph assembly module for Deep Agents.
Provides [`create_deep_agent`][deepagents.graph.create_deep_agent], the main entry
point for constructing a fully configured deep agent with planning, filesystem,
subagent, and summarization middleware.
"""
import logging
from collections.abc import Callable, Sequence... | 945 | 45,148 |
deepagents | libs/deepagents/deepagents/profiles/__init__.py | .py | """Public beta APIs for model and harness profiles.
!!! beta
`deepagents.profiles` exposes beta APIs that may receive minor changes in
future releases. Refer to the [versioning documentation](https://docs.langchain.com/oss/python/versioning)
for more details.
Profiles let Deep Agents tailor behavior to a... | 62 | 2,533 |
deepagents | libs/deepagents/deepagents/profiles/_keys.py | .py | """Shared helpers for profile registry keys.
Both `harness_profiles` and `provider_profiles` use the same `provider` or
`provider:model` key shape, so the validation and lookup helpers live here
to avoid duplication.
"""
from __future__ import annotations
def validate_profile_key(key: str) -> None:
"""Validate ... | 43 | 1,714 |
deepagents | libs/deepagents/deepagents/profiles/_builtin_profiles.py | .py | """Bootstrap for built-in and third-party profile plugins.
Built-in provider and harness profiles are registered via explicit
module imports — not entry points — so a malformed or missing
`dist-info` in the environment cannot silently disable the SDK's own
defaults. Third parties plug in via `importlib.metadata` entry... | 237 | 10,013 |
deepagents | libs/deepagents/deepagents/profiles/harness/_nvidia_nemotron_3_ultra.py | .py | """Built-in NVIDIA Nemotron 3 Ultra harness profile.
The profile is scoped to Nemotron 3 Ultra model specs. It adds lightweight
prompt guidance and middleware for observed tool-calling, filesystem,
context-management, and final-answer behaviors in agentic workloads.
"""
from __future__ import annotations
import asyn... | 1,827 | 75,667 |
deepagents | libs/deepagents/deepagents/profiles/harness/_openai_codex.py | .py | """Built-in OpenAI Codex harness profile.
Registers a `HarnessProfile` for each OpenAI Codex model spec with a
behavior-shaping `system_prompt_suffix` that aligns Deep Agents'
runtime defaults with how Codex was trained to operate — autonomous
senior engineer demeanor, bias to action, parallel tool use, and TODO
hygie... | 89 | 3,434 |
deepagents | libs/deepagents/deepagents/profiles/harness/__init__.py | .py | """Harness profile package: `HarnessProfile` API and built-in registrations.
Individual built-in modules expose a zero-arg `register()` callable; the lazy
`_builtin_profiles` bootstrap invokes them once on first profile-registry
access. Built-ins must not register at module import time — registration runs
under the bo... | 23 | 744 |
deepagents | libs/deepagents/deepagents/profiles/harness/_anthropic_opus_4_7.py | .py | """Built-in Claude Opus 4.7 harness profile.
Layers a system-prompt suffix onto `anthropic:claude-opus-4-7` tuned to
Claude Opus 4.7's documented behaviors:
- Universal Claude guidance that applies to every recent Claude —
parallel tool calls, grounded (non-speculative) answers, and
post-tool-result reflection.
-... | 57 | 3,443 |
deepagents | libs/deepagents/deepagents/profiles/harness/_anthropic_haiku_4_5.py | .py | """Built-in Claude Haiku 4.5 harness profile.
Layers Anthropic's universal Claude guidance onto
`anthropic:claude-haiku-4-5` — parallel tool calls, grounded (non-
speculative) answers, and post-tool-result reflection.
No Claude-Haiku-4.5-specific overlays. Anthropic's published prompting
guide does not carve out Haik... | 53 | 3,174 |
deepagents | libs/deepagents/deepagents/profiles/harness/harness_profiles.py | .py | """Beta APIs for configuring deep agent runtime behavior.
!!! beta
`deepagents.profiles` exposes beta APIs that may receive minor changes in
future releases. Refer to the [versioning documentation](https://docs.langchain.com/oss/python/versioning)
for more details.
Harness profiles declare how `create_de... | 1,323 | 58,341 |
deepagents | libs/deepagents/deepagents/profiles/harness/_anthropic_sonnet_4_6.py | .py | """Built-in Claude Sonnet 4.6 harness profile.
Layers Anthropic's universal Claude guidance onto
`anthropic:claude-sonnet-4-6` — parallel tool calls, grounded (non-
speculative) answers, and post-tool-result reflection.
No Claude-Sonnet-4.6-specific overlays. Anthropic's published guidance
for Sonnet 4.6 centers on A... | 53 | 3,162 |
deepagents | libs/deepagents/deepagents/profiles/provider/_openai.py | .py | """Built-in OpenAI provider profile.
Enables the OpenAI Responses API by default for all `openai:*` models via
`use_responses_api=True`. Users may layer additional kwargs on top
via `register_provider_profile("openai", ...)`.
Registered directly by `_ensure_builtin_profiles_loaded` during the
first profile-registry a... | 25 | 806 |
deepagents | libs/deepagents/deepagents/profiles/provider/__init__.py | .py | """Provider profile package: `ProviderProfile` API and built-in providers."""
from deepagents.profiles.provider.provider_profiles import (
ProviderProfile,
apply_provider_profile,
get_provider_profile,
register_provider_profile,
)
__all__ = [
"ProviderProfile",
"apply_provider_profile",
"g... | 16 | 377 |
deepagents | libs/deepagents/deepagents/profiles/provider/_openrouter.py | .py | """Built-in OpenRouter provider profile and helpers.
Enforces the minimum `langchain-openrouter` version and injects default
app-attribution headers when the corresponding environment variables are not
set. Users may layer additional kwargs on top via
`register_provider_profile("openrouter", ...)`.
Registered directl... | 131 | 5,263 |
deepagents | libs/deepagents/deepagents/profiles/provider/_nvidia.py | .py | """Built-in NVIDIA provider profile and helpers.
Injects Deep Agents app-origin attribution into NVIDIA NIM requests via the
header supported by `langchain-nvidia-ai-endpoints`.
Registered directly by `_ensure_builtin_profiles_loaded` during the first
profile-registry access. Not exposed as an `importlib.metadata` en... | 51 | 1,574 |
deepagents | libs/deepagents/deepagents/profiles/provider/provider_profiles.py | .py | """Beta APIs for configuring model-construction behavior.
!!! beta
`deepagents.profiles` exposes beta APIs that may receive minor changes in
future releases. Refer to the [versioning documentation](https://docs.langchain.com/oss/python/versioning)
for more details.
Provider profiles declare how Deep Agen... | 456 | 18,431 |
deepagents | libs/deepagents/deepagents/_api/__init__.py | .py | """Internal helpers for `deepagents`.
Modules under this package are private. Their API is allowed to change between
minor releases without deprecation.
"""
| 6 | 158 |
deepagents | libs/deepagents/deepagents/_api/deprecation.py | .py | """Adapter for `langchain_core`'s private deprecation helpers.
Centralizes the import surface so an upstream rename or move is a one-file
change.
Re-exports:
- `deprecated`: decorator for callables, classes, and properties.
- `warn_deprecated`: helper for parameter/value-level deprecations where the
callable itse... | 132 | 5,095 |
deepagents | libs/deepagents/deepagents/backends/composite.py | .py | """Composite backend that routes file operations by path prefix.
Routes operations to different backends based on path prefixes. Use this when
you need different storage strategies for different paths (e.g., state for
temp files, persistent store for memories).
"""
from collections import defaultdict
from collections... | 955 | 38,945 |
deepagents | libs/deepagents/deepagents/backends/local_shell.py | .py | """`LocalShellBackend`: Filesystem backend with unrestricted local shell execution.
This backend extends `FilesystemBackend` to add shell command execution on
the local host system. It provides NO sandboxing or isolation - all operations
run directly on the host machine with full system access.
"""
from __future__ im... | 365 | 14,469 |
deepagents | libs/deepagents/deepagents/backends/filesystem.py | .py | """`FilesystemBackend`: Read and write files directly from the filesystem."""
import asyncio
import base64
import errno
import functools
import json
import logging
import os
import shutil
import subprocess
import threading
import time
from bisect import bisect_left, bisect_right
from datetime import datetime
from path... | 1,527 | 68,378 |
deepagents | libs/deepagents/deepagents/backends/context_hub.py | .py | """`ContextHubBackend`: Store files in a LangSmith Hub agent repo (persistent)."""
from __future__ import annotations
import fnmatch
import logging
import os
import re
import threading
import time
from dataclasses import dataclass, field
from typing import TYPE_CHECKING
from urllib.parse import urlsplit
from langsmi... | 699 | 26,786 |
deepagents | libs/deepagents/deepagents/backends/state.py | .py | """`StateBackend`: Store files in LangGraph agent state (ephemeral)."""
import base64
from typing import Any
from langchain_core.runnables import RunnableConfig
from langgraph._internal._constants import CONFIG_KEY_READ, CONFIG_KEY_SEND
from langgraph.config import get_config
from deepagents.backends.protocol import... | 361 | 13,484 |
deepagents | libs/deepagents/deepagents/backends/utils.py | .py | """Shared utility functions for memory backend implementations.
This module contains both user-facing string formatters and structured
helpers used by backends and the composite router. Structured helpers
enable composition without fragile string parsing.
"""
import functools
import logging
import os
import re
from c... | 1,048 | 40,418 |
deepagents | libs/deepagents/deepagents/backends/langsmith.py | .py | """LangSmith sandbox backend implementation."""
from __future__ import annotations
import base64
import logging
from typing import TYPE_CHECKING
from deepagents.backends.protocol import (
ExecuteResponse,
FileData,
FileDownloadResponse,
FileUploadResponse,
ReadResult,
WriteResult,
)
from deep... | 354 | 15,042 |
deepagents | libs/deepagents/deepagents/backends/store.py | .py | """`StoreBackend`: Adapter for LangGraph's BaseStore (persistent, cross-thread)."""
import base64
import re
from collections.abc import Callable
from typing import TYPE_CHECKING, Any, cast
from langgraph.config import get_store
from langgraph.runtime import get_runtime
from langgraph.store.base import BaseStore, Item... | 706 | 25,528 |
deepagents | libs/deepagents/deepagents/backends/__init__.py | .py | """Memory backends for pluggable file storage."""
from deepagents.backends.composite import CompositeBackend
from deepagents.backends.context_hub import ContextHubBackend
from deepagents.backends.filesystem import FilesystemBackend
from deepagents.backends.langsmith import LangSmithSandbox
from deepagents.backends.loc... | 24 | 812 |
deepagents | libs/deepagents/deepagents/backends/protocol.py | .py | """Protocol definition for pluggable memory backends.
This module defines the `BackendProtocol` that all backend implementations
must follow. Backends can store files in different locations (state, filesystem,
database, etc.) and provide a uniform interface for file operations.
"""
import abc
import asyncio
import in... | 929 | 33,487 |
deepagents | libs/deepagents/deepagents/backends/sandbox.py | .py | """Base sandbox implementation.
[`BaseSandbox`][deepagents.backends.sandbox.BaseSandbox] implements
[`SandboxBackendProtocol`][deepagents.backends.protocol.SandboxBackendProtocol].
File listing, grep, glob, and read use shell commands via `execute()`. Write
delegates content transfer to `upload_files()`. Edit uses se... | 1,502 | 65,204 |
deepagents | libs/deepagents/deepagents/middleware/_utils.py | .py | """Utility functions for middleware."""
from langchain_core.messages import ContentBlock, SystemMessage
def append_to_system_message(
system_message: SystemMessage | None,
text: str,
) -> SystemMessage:
"""Append text to a system message.
Args:
system_message: Existing system message or None... | 24 | 700 |
deepagents | libs/deepagents/deepagents/middleware/_video.py | .py | """Video frame extraction for filesystem reads.
This module is the boundary between Deep Agents middleware and the optional
video backend (PyAV). It imports PyAV lazily so a `deepagents` install without
the `[video]` extra stays lightweight; the import only fires when the agent
actually tries to read a video.
For eac... | 405 | 17,043 |
deepagents | libs/deepagents/deepagents/middleware/filesystem.py | .py | """Middleware for providing filesystem tools to an agent."""
# ruff: noqa: E501
import asyncio
import base64
import concurrent.futures
import contextlib
import contextvars
import mimetypes
import threading
import uuid
from binascii import Error as BinasciiError
from collections.abc import Awaitable, Callable, Mapping
... | 3,495 | 154,547 |
deepagents | libs/deepagents/deepagents/middleware/_state.py | .py | """Helpers for working with Deep Agents state schemas."""
from __future__ import annotations
import logging
from typing import Annotated, get_args, get_origin, get_type_hints
from langchain.agents.middleware.types import PrivateStateAttr
logger = logging.getLogger(__name__)
def private_state_field_names(*state_sc... | 50 | 2,011 |
deepagents | libs/deepagents/deepagents/middleware/subagents.py | .py | """Middleware for providing subagents to an agent via a `task` tool."""
import contextlib
import dataclasses
import json
from collections.abc import Awaitable, Callable, Generator, Sequence
from typing import Any, NotRequired, TypedDict, cast
from langchain.agents import create_agent
from langchain.agents.middleware ... | 743 | 29,580 |
deepagents | libs/deepagents/deepagents/middleware/_tool_exclusion.py | .py | """Middleware for filtering excluded tools from model requests."""
from __future__ import annotations
from typing import TYPE_CHECKING, Any
from langchain.agents.middleware.types import AgentMiddleware
if TYPE_CHECKING:
from collections.abc import Awaitable, Callable
from langchain.agents.middleware.types ... | 66 | 2,339 |
deepagents | libs/deepagents/deepagents/middleware/__init__.py | .py | """Middleware for the Deep Agents agent.
## Overview
The LLM receives tools through two paths:
1. **SDK middleware** (this package) -- tools, system-prompt injection, and
request interception that any SDK consumer gets automatically.
2. **Consumer-provided tools** -- plain callable functions passed via the
`... | 105 | 3,455 |
deepagents | libs/deepagents/deepagents/middleware/_message_eviction.py | .py | # ruff: noqa: E501
"""Shared helpers for evicting/clipping large message content with a head+tail preview.
Used by:
- `FilesystemMiddleware` — proactive per-tool-call offload when a tool result
exceeds its configured size threshold.
- `SummarizationMiddleware` — reactive tail-clipping in the fallback
summariz... | 163 | 6,751 |
deepagents | libs/deepagents/deepagents/middleware/skills.py | .py | """Skills middleware for loading and exposing agent skills to the system prompt.
This module implements Anthropic's agent skills pattern with progressive disclosure,
loading skills from backend storage via configurable sources.
## Architecture
Skills are loaded from one or more **sources** - paths in a backend where... | 1,054 | 39,646 |
deepagents | libs/deepagents/deepagents/middleware/rubric.py | .py | # ruff: noqa: E501 # Long prompt strings in GRADER_SYSTEM_PROMPT
"""Rubric middleware for self-evaluated agent iteration.
`RubricMiddleware` lets a caller declare *what done looks like* via a
rubric. Each time the agent would otherwise finish — i.e. the model
returns a response with no further tool calls — the middle... | 1,025 | 41,626 |
deepagents | libs/deepagents/deepagents/middleware/patch_tool_calls.py | .py | """Middleware to patch dangling tool calls in the messages history."""
from typing import Any
from langchain.agents.middleware import AgentMiddleware, AgentState
from langchain_core.messages import AIMessage, AnyMessage, RemoveMessage, ToolMessage
from langgraph.graph.message import REMOVE_ALL_MESSAGES
from langgraph... | 47 | 2,149 |
deepagents | libs/deepagents/deepagents/middleware/permissions.py | .py | """Backward-compatible re-export for filesystem permissions."""
from deepagents.middleware.filesystem import FilesystemPermission # Re-exported for backwards compatibility.
__all__ = ["FilesystemPermission"]
| 6 | 211 |
deepagents | libs/deepagents/deepagents/middleware/_fs_interrupt.py | .py | """Glue between `FilesystemPermission` rules and `HumanInTheLoopMiddleware`.
`FilesystemMiddleware` itself doesn't know about HITL — it only enforces deny
rules and filters denied results. The graph-assembly code in
`deepagents.graph` calls `_build_interrupt_on_from_permissions` to turn the
filesystem permissions into... | 184 | 8,553 |
deepagents | libs/deepagents/deepagents/middleware/_prompt_caching.py | .py | """Provider-specific prompt-caching middleware helpers."""
import logging
from importlib import import_module
from typing import Any, cast
from langchain.agents.middleware.types import AgentMiddleware
from langchain_anthropic.middleware import AnthropicPromptCachingMiddleware
logger = logging.getLogger(__name__)
d... | 50 | 2,312 |
deepagents | libs/deepagents/deepagents/middleware/summarization.py | .py | """Summarization middleware for automatic and tool-based conversation compaction.
This module provides two middleware classes and a convenience factory:
- `SummarizationMiddleware` — automatically compacts the conversation when token
usage exceeds a configurable threshold.
Older messages are summarized via a... | 2,155 | 89,359 |
deepagents | libs/deepagents/deepagents/middleware/_overflow_clip.py | .py | """Read-side clipping for the summarization-on-overflow fallback path.
When `SummarizationMiddleware`'s `wrap_model_call` catches a
`ContextOverflowError`, it falls through to summarization and *also* invokes
`_clip_overflow_tail` (or its async variant) to shrink the trailing
ToolMessage batch in the preserved suffix.... | 207 | 8,500 |
deepagents | libs/deepagents/deepagents/middleware/async_subagents.py | .py | """Middleware for async subagents running on remote Agent Protocol servers.
Async subagents use the LangGraph SDK to launch background runs on remote
[Agent Protocol](https://github.com/langchain-ai/agent-protocol) servers.
Unlike synchronous subagents (which block until completion), async subagents
return a task ID i... | 929 | 36,290 |
deepagents | libs/deepagents/deepagents/middleware/memory.py | .py | # ruff: noqa: E501 # Long prompt strings in MEMORY_SYSTEM_PROMPT
"""Middleware for loading agent memory/context from AGENTS.md files.
This module implements support for the AGENTS.md specification (https://agents.md/),
loading memory/context from configurable sources and injecting into the system prompt.
## Overview... | 413 | 17,867 |
deepagents | libs/deepagents/tests/utils.py | .py | from typing import ClassVar
from langchain.agents.middleware import AgentMiddleware, AgentState
from langchain.tools import ToolRuntime
from langchain_core.messages import ToolMessage
from langchain_core.tools import BaseTool, tool
from langgraph.types import Command
def assert_all_deepagent_qualities(agent):
as... | 116 | 3,937 |
deepagents | libs/deepagents/tests/unit_tests/test_todo_middleware.py | .py | """Tests for TodoListMiddleware functionality.
This module contains tests for the todo list middleware, focusing on how it handles
write_todos tool calls, state management, and edge cases.
"""
from langchain.agents import create_agent
from langchain.agents.middleware import TodoListMiddleware
from langchain_core.mess... | 103 | 4,777 |
deepagents | libs/deepagents/tests/unit_tests/test_async_subagents.py | .py | """Tests for async subagent middleware functionality."""
import json
from typing import Any, TypeVar
from unittest.mock import MagicMock, patch
import pytest
from langchain.tools import ToolRuntime
from langgraph.types import Command
from deepagents.middleware.async_subagents import (
AsyncSubAgent,
AsyncSub... | 897 | 34,580 |
deepagents | libs/deepagents/tests/unit_tests/test_eviction_replay.py | .py | """Tests for HumanMessage eviction with DeltaChannel replay.
Verifies that emitting only `[tagged]` (reusing the original message's
ID) correctly deduplicates on DeltaChannel replay — without needing a
`REMOVE_ALL_MESSAGES` sentinel that would clobber the AIMessage written
in the same super-step.
"""
from typing impo... | 105 | 4,117 |
deepagents | libs/deepagents/tests/unit_tests/test_end_to_end.py | .py | """End-to-end unit tests for deepagents with fake LLM models."""
import base64
import json
from collections.abc import Awaitable, Callable, Iterator, Sequence
from pathlib import Path
from typing import Any
from unittest.mock import MagicMock, patch
import pytest
from langchain.agents.middleware import AgentMiddlewar... | 4,936 | 203,579 |
deepagents | libs/deepagents/tests/unit_tests/test_harness_profiles.py | .py | """Tests for harness-profile config and sub-profile serialization."""
from __future__ import annotations
from unittest.mock import MagicMock
import pytest
from deepagents import (
AsyncSubAgentMiddleware,
GeneralPurposeSubagentProfile,
HarnessProfile,
HarnessProfileConfig,
)
from deepagents.middlewa... | 410 | 18,501 |
deepagents | libs/deepagents/tests/unit_tests/test_artifacts_root.py | .py | """Tests for artifacts_root parameterization."""
from langchain_core.messages import ToolMessage
from langgraph.store.memory import InMemoryStore
from deepagents.backends.composite import CompositeBackend
from deepagents.backends.state import StateBackend
from deepagents.backends.store import StoreBackend
from deepag... | 163 | 7,428 |
deepagents | libs/deepagents/tests/unit_tests/test_middleware_async.py | .py | """Async tests for middleware filesystem tools."""
import asyncio
from unittest.mock import patch
from langchain.tools import ToolRuntime
from langchain_core.messages import ToolMessage
from langgraph.store.memory import InMemoryStore
import deepagents.middleware.filesystem as filesystem_middleware
from deepagents.b... | 1,096 | 44,055 |
deepagents | libs/deepagents/tests/unit_tests/test_file_system_tools_async.py | .py | """Async unit tests for file system tools path validation.
This module contains async versions of the path validation error handling tests.
"""
from langchain_core.messages import AIMessage, HumanMessage, ToolMessage
from langgraph.checkpoint.memory import InMemorySaver
from deepagents.graph import create_deep_agent... | 181 | 6,459 |
deepagents | libs/deepagents/tests/unit_tests/test_graph.py | .py | """Unit tests for deepagents.graph module."""
from __future__ import annotations
import logging
import shutil
import subprocess
import sys
import warnings
from pathlib import Path
from typing import TYPE_CHECKING, Any, cast
from unittest.mock import MagicMock, patch
import pytest
from langchain.agents.middleware imp... | 2,938 | 134,896 |
deepagents | libs/deepagents/tests/unit_tests/test_middleware.py | .py | import mimetypes
import time
from unittest.mock import MagicMock, patch
import pytest
from langchain.agents import create_agent
from langchain.agents.middleware.types import ToolCallRequest
from langchain.tools import ToolRuntime
from langchain_core.messages import (
AIMessage,
HumanMessage,
RemoveMessage,... | 3,707 | 161,421 |
deepagents | libs/deepagents/tests/unit_tests/test_deep_agent_streaming.py | .py | """Integration tests for create_deep_agent streaming via stream_events(version="v3").
Drives a real `create_deep_agent` graph end-to-end through the
streaming pipeline and asserts that subagents are surfaced as typed
child streams with the right projections. Runs in both sync and
async paths.
"""
import asyncio
from ... | 339 | 11,646 |
deepagents | libs/deepagents/tests/unit_tests/test_version.py | .py | """Test that package version is consistent across configuration files."""
from __future__ import annotations
import json
import tomllib
from importlib.metadata import PathDistribution
from pathlib import Path
from typing import TYPE_CHECKING
from unittest.mock import MagicMock, patch
import pytest
import deepagents... | 506 | 21,681 |
deepagents | libs/deepagents/tests/unit_tests/test_subagents.py | .py | """Tests for sub-agent middleware functionality.
This module contains tests for the subagent system, focusing on how subagents
are invoked, how they return results, and how state is managed between parent
and child agents.
"""
import dataclasses
import json
import uuid
from collections.abc import Callable, Sequence
f... | 3,119 | 129,040 |
deepagents | libs/deepagents/tests/unit_tests/test_local_sandbox_operations.py | .py | # ruff: noqa: S108, RUF001
"""Unit tests for BaseSandbox file operations using local subprocess.
This module tests the core file operations implemented in BaseSandbox:
- write(): Create new files
- read(): Read file contents with line numbers
- edit(): String replacement in files
- ls_info(): List directory contents
-... | 1,769 | 78,261 |
deepagents | libs/deepagents/tests/unit_tests/test_permissions.py | .py | """Unit tests for filesystem permission enforcement in `FilesystemMiddleware`."""
import threading
import pytest
from langchain.tools import ToolRuntime
from langchain.tools.tool_node import ToolCallRequest
from langchain_core.language_models.fake_chat_models import GenericFakeChatModel
from langchain_core.messages i... | 1,596 | 81,260 |
deepagents | libs/deepagents/tests/unit_tests/test_file_system_tools.py | .py | """End to end unit tests that verify that the deepagents can use file system tools.
At the moment these tests are written against the state backend, but we will need
to extend them to other backends as well.
"""
import pytest
from langchain_core.messages import AIMessage, HumanMessage, ToolMessage
from langgraph.chec... | 590 | 22,014 |
deepagents | libs/deepagents/tests/unit_tests/chat_model.py | .py | """Fake chat models for testing purposes."""
import re
from collections.abc import Callable, Iterator, Sequence
from typing import Any, cast
from langchain_core.callbacks import (
CallbackManagerForLLMRun,
)
from langchain_core.language_models import LanguageModelInput
from langchain_core.language_models.chat_mod... | 250 | 10,373 |
deepagents | libs/deepagents/tests/unit_tests/test_messages_reducer.py | .py | """Tests for DeltaChannel message ID stability.
IDs are assigned by LangGraph's ensure_message_ids() before writes are
serialised to the checkpoint. These tests verify the end-to-end property:
get_state() always returns messages with stable, non-None IDs — both within
a single invocation and across resumed threads.
""... | 136 | 5,695 |
deepagents | libs/deepagents/tests/unit_tests/test_models.py | .py | """Tests for deepagents._models helpers and internal profile registries."""
import logging
import os
import threading
from collections.abc import Iterator
from importlib.metadata import PackageNotFoundError
from unittest.mock import MagicMock, patch
import pytest
from langchain_core.language_models import BaseChatMod... | 2,251 | 95,281 |
deepagents | libs/deepagents/tests/unit_tests/test_local_shell.py | .py | """Unit tests for LocalShellBackend per-command timeout features."""
import subprocess
import sys
from unittest.mock import patch
import pytest
from deepagents.backends.local_shell import DEFAULT_EXECUTE_TIMEOUT, LocalShellBackend
class TestDefaultTimeoutConstant:
"""Tests for the named default timeout constan... | 99 | 4,471 |
deepagents | libs/deepagents/tests/unit_tests/test_nemotron_ultra_profile.py | .py | """Tests for the NVIDIA Nemotron 3 Ultra harness profile."""
from __future__ import annotations
from types import SimpleNamespace
from typing import TYPE_CHECKING
from langchain.agents.middleware.types import ToolCallRequest
from langchain.tools import ToolRuntime
from langchain_core.messages import AIMessage, Human... | 968 | 37,184 |
deepagents | libs/deepagents/tests/unit_tests/conftest.py | .py | """Shared fixtures for unit tests."""
from __future__ import annotations
import importlib
import inspect
import pkgutil
import pytest
import deepagents
from deepagents._api.deprecation import reset_deprecation_dedupe
def _is_deprecated_target(value: object) -> bool:
"""Return whether `value` (or its `fget`) c... | 99 | 4,004 |
deepagents | libs/deepagents/tests/unit_tests/_typing_fixtures/context_aware_middleware.py | .py | """Type-checking fixture for context-aware middleware on `create_deep_agent`.
This module is not executed; it is type-checked by `ty` from
`test_graph.py::TestMiddlewareTyping` to guard against regressions where the
`middleware` parameter pins `ContextT` to `None` (see issue #4051).
"""
from dataclasses import datacl... | 31 | 811 |
deepagents | libs/deepagents/tests/unit_tests/smoke_tests/test_system_prompt.py | .py | from __future__ import annotations
import json
from pathlib import Path
from typing import Any
import pytest
from langchain_core.messages import AIMessage, HumanMessage, SystemMessage
from langchain_core.utils.function_calling import convert_to_openai_tool
from langgraph.store.memory import InMemoryStore
from deepag... | 433 | 15,783 |
deepagents | libs/deepagents/tests/unit_tests/smoke_tests/conftest.py | .py | from __future__ import annotations
from pathlib import Path
import pytest
from deepagents.middleware import filesystem
def pytest_addoption(parser: pytest.Parser) -> None:
parser.addoption(
"--update-snapshots",
action="store_true",
default=False,
help="Update smoke test snapsho... | 48 | 1,676 |
deepagents | libs/deepagents/tests/unit_tests/_api/test_deprecation.py | .py | """Tests for the `_api/deprecation` adapter."""
import warnings
from collections.abc import Callable
import pytest
from deepagents._api.deprecation import (
LangChainDeprecationWarning,
deprecated,
reset_deprecation_dedupe,
suppress_langchain_deprecation_warning,
warn_deprecated,
)
from tests.uni... | 234 | 7,883 |
deepagents | libs/deepagents/tests/unit_tests/backends/test_filesystem_backend.py | .py | import base64
import io
import json
import logging
import shutil
import subprocess
import sys
import threading
import warnings
from collections.abc import Iterator
from pathlib import Path
from typing import Self
import pytest
from langchain_core.messages import ToolMessage
from deepagents.backends import filesystem ... | 2,654 | 109,585 |
deepagents | libs/deepagents/tests/unit_tests/backends/test_context_hub_backend.py | .py | """Tests for ContextHubBackend with mocked langsmith.Client."""
from __future__ import annotations
import threading
import time
from concurrent.futures import ThreadPoolExecutor
from types import SimpleNamespace
from typing import TYPE_CHECKING, Any
from unittest.mock import MagicMock, patch
import pytest
from langs... | 1,249 | 48,433 |
deepagents | libs/deepagents/tests/unit_tests/backends/test_state_backend.py | .py | """Unit tests for StateBackend."""
from typing import Any
import pytest
from deepagents.backends.state import StateBackend
def test_state_backend_raises_outside_graph_context():
"""StateBackend operations outside a graph context should raise RuntimeError."""
be = StateBackend()
with pytest.raises(Runti... | 112 | 4,271 |
deepagents | libs/deepagents/tests/unit_tests/backends/test_protocol.py | .py | """Tests for BackendProtocol and SandboxBackendProtocol base class behavior.
Verifies that unimplemented protocol methods raise NotImplementedError
instead of silently returning None.
"""
import asyncio
import errno
from unittest.mock import patch
import pytest
from deepagents.backends.filesystem import _map_except... | 344 | 14,002 |
deepagents | libs/deepagents/tests/unit_tests/backends/test_state_backend_async.py | .py | """Async unit tests for StateBackend.
StateBackend requires a LangGraph graph execution context (get_config()).
Functional tests (write/read/edit/ls/grep/glob) are covered by
TestStateBackendConfigKeys in test_end_to_end.py using create_deep_agent
with a fake model. This file only contains async-specific error tests.... | 19 | 698 |
deepagents | libs/deepagents/tests/unit_tests/backends/test_composite_backend.py | .py | from pathlib import Path
import pytest
from langchain_core.messages import ToolMessage
from langgraph.store.memory import InMemoryStore
from deepagents.backends.composite import CompositeBackend, _route_for_path
from deepagents.backends.filesystem import FilesystemBackend
from deepagents.backends.protocol import (
... | 1,774 | 68,821 |
deepagents | libs/deepagents/tests/unit_tests/backends/test_filesystem_backend_async.py | .py | """Async tests for FilesystemBackend."""
import time
from pathlib import Path
import pytest
from langchain_core.messages import ToolMessage
from deepagents.backends import filesystem as fs_module
from deepagents.backends.filesystem import FilesystemBackend
from deepagents.backends.protocol import EditResult, ReadRes... | 593 | 21,494 |
deepagents | libs/deepagents/tests/unit_tests/backends/test_timeout_compat.py | .py | """Tests for timeout compatibility guards.
Verifies that `execute_accepts_timeout` correctly detects whether a backend's
`execute` method accepts a `timeout` keyword argument, and that callers handle
the result appropriately.
"""
import logging
import pytest
from deepagents.backends.composite import CompositeBacken... | 192 | 6,851 |
deepagents | libs/deepagents/tests/unit_tests/backends/test_store_backend.py | .py | from typing import Any, Never
import pytest
from langchain_core.messages import ToolMessage
from langgraph.runtime import Runtime
from langgraph.store.base import PutOp
from langgraph.store.memory import InMemoryStore
from deepagents.backends.protocol import EditResult, ReadResult, WriteResult
from deepagents.backend... | 731 | 26,264 |
deepagents | libs/deepagents/tests/unit_tests/backends/test_local_shell_backend.py | .py | """Unit tests for LocalShellBackend."""
import sys
import tempfile
import warnings
from pathlib import Path
import pytest
from deepagents.backends.local_shell import LocalShellBackend
from deepagents.backends.protocol import ExecuteResponse
pytestmark = pytest.mark.skipif(sys.platform == "win32", reason="LocalShell... | 333 | 12,452 |
deepagents | libs/deepagents/tests/unit_tests/backends/test_sandbox_backend.py | .py | """Tests for BaseSandbox backend operations.
Verifies that read and edit (small payload) use execute() for server-side
operations, write uses upload_files, edit (large payload) uploads old/new as
temp files with a server-side replace script, and command templates format
correctly.
"""
import base64
import json
import... | 2,301 | 85,438 |
deepagents | libs/deepagents/tests/unit_tests/backends/test_file_format.py | .py | """Tests for current file data storage format and helpers."""
import base64
import pytest
from langgraph.store.memory import InMemoryStore
from deepagents.backends.store import StoreBackend
from deepagents.backends.utils import (
compile_grep_include_glob,
create_file_data,
file_data_to_string,
grep_... | 181 | 6,140 |
deepagents | libs/deepagents/tests/unit_tests/backends/test_composite_backend_async.py | .py | """Async tests for CompositeBackend."""
from pathlib import Path
import pytest
from langgraph.store.memory import InMemoryStore
from deepagents.backends.composite import CompositeBackend
from deepagents.backends.filesystem import FilesystemBackend
from deepagents.backends.protocol import (
BackendProtocol,
E... | 1,164 | 45,070 |
deepagents | libs/deepagents/tests/unit_tests/backends/test_langsmith_sandbox.py | .py | """Tests for LangSmithSandbox backend."""
from __future__ import annotations
import base64
from types import SimpleNamespace
from unittest.mock import AsyncMock, MagicMock
import pytest
from langsmith.sandbox import ResourceNotFoundError, SandboxClientError
from deepagents.backends import sandbox as base_sandbox
fr... | 622 | 20,661 |
deepagents | libs/deepagents/tests/unit_tests/backends/test_store_backend_async.py | .py | """Async tests for StoreBackend."""
from langchain_core.messages import ToolMessage
from langgraph.store.memory import InMemoryStore
from deepagents.backends.protocol import EditResult, ReadResult, WriteResult
from deepagents.backends.store import StoreBackend
from deepagents.middleware.filesystem import FilesystemMi... | 425 | 15,730 |
deepagents | libs/deepagents/tests/unit_tests/backends/test_utils.py | .py | """Tests for backends/utils.py utility functions."""
from typing import Any
import pytest
from langchain_core.messages.content import ContentBlock
from pydantic import TypeAdapter
from deepagents.backends.protocol import FileData, ReadResult
from deepagents.backends.utils import (
_EXTENSION_TO_FILE_TYPE,
_g... | 614 | 26,459 |
deepagents | libs/deepagents/tests/unit_tests/middleware/test_compact_tool.py | .py | """Unit tests for the compact_conversation tool via SummarizationToolMiddleware."""
from __future__ import annotations
from inspect import Parameter, signature
from typing import Any
from unittest.mock import MagicMock, patch
import pytest
from langchain.agents.middleware.types import ModelRequest
from langchain_cor... | 791 | 33,793 |
deepagents | libs/deepagents/tests/unit_tests/middleware/test_skills_middleware_async.py | .py | """Async unit tests for skills middleware with FilesystemBackend.
This module contains async versions of skills middleware tests.
"""
import logging
from pathlib import Path, PurePosixPath
from types import SimpleNamespace
from unittest.mock import AsyncMock, MagicMock
import pytest
from langchain.agents import crea... | 521 | 18,504 |
deepagents | libs/deepagents/tests/unit_tests/middleware/test_rubric_middleware.py | .py | """Unit tests for `RubricMiddleware`.
These tests cover edge cases and pure-function behavior: construction
validation, `before_agent` rubric-change detection, grader-plumbing
internals, transcript building, and rubric-tracking across multi-turn
invocations. The grader is stubbed via `monkeypatch` on
`_grade`/`_agrade... | 1,221 | 48,610 |
deepagents | libs/deepagents/tests/unit_tests/middleware/test_memory_middleware.py | .py | """Unit tests for memory middleware with FilesystemBackend.
This module tests the memory middleware using end-to-end tests with fake chat models
and temporary directories with the FilesystemBackend in normal (non-virtual) mode.
"""
from contextlib import contextmanager
from datetime import UTC, datetime
from pathlib ... | 1,188 | 44,942 |
deepagents | libs/deepagents/tests/unit_tests/middleware/test_skills_middleware.py | .py | """Unit tests for skills middleware with FilesystemBackend.
This module tests the skills middleware and helper functions using temporary
directories and the FilesystemBackend in normal (non-virtual) mode.
"""
import logging
from contextlib import contextmanager
from datetime import UTC, datetime
from pathlib import P... | 2,159 | 75,180 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.