LangChain Deep Agents with Oracle
Use langchain-oci to connect LangChain Deep Agents to OCI Generative AI, other LangChain model providers, and Oracle AI Database.
Deep Agents is an open source agent harness in the LangChain ecosystem for long-running, multi-step work. The Oracle integration is not a separate or forked agent framework. The create_deepagents_agent() factory composes Oracle capabilities with the upstream deepagents.create_deep_agent() implementation and returns a compiled LangGraph graph.
Why Use LangChain Deep Agents with Oracle
Use the integration when an agent must plan research, work across a large body of Oracle data, preserve intermediate files, or resume work in a later session.
The upstream Deep Agents harness provides planning, subagent delegation, a virtual file system, and the agent loop. The Oracle integration adds the following options:
- OCI model access: Use an OCI Generative AI chat model for reasoning and synthesis.
- Oracle-grounded retrieval: Register an
ADBdatastore backed byOracleVSand Oracle AI Vector Search. - Generated retrieval tools: Create
stats,search, andget_documenttools automatically from registered datastores. - Hybrid search: Combine semantic vector retrieval with Oracle Text keyword retrieval. The generated
searchtool for anADBdatastore requires an Oracle Text search index. - Datastore routing: Route a query across multiple registered datastores by comparing it with each
datastore_description. - Durable state: Combine the agent with
OracleSaverfor thread checkpoints. - Application-managed memory: Store namespaced, vector-searchable values in
OracleStore, and expose them through a tool or middleware when the agent must recall them. - Persistent working files: Map the Deep Agents virtual file system to
OracleStoreby usingStoreBackend. - Model flexibility: Supply any prebuilt LangChain chat model or embedding model while keeping Oracle AI Database as the retrieval and persistence layer.
Architecture
A LangChain Deep Agent with Oracle typically follows this flow:
- Prepare data: Load documents and embeddings into an Oracle vector table, and create the Oracle Text search index required by the generated ADB search tool.
- Register a datastore: Configure
langchain_oci.datastores.ADBwith the table name and a short description of the indexed content. - Choose models: Use the OCI Generative AI model and default OCI embeddings, or pass prebuilt LangChain chat and embedding models.
- Create the agent: Call
create_deepagents_agent()with the datastore, embedding model, prompt, and optional Deep Agents features. - Use generated tools: Let the agent inspect datastore statistics, search for relevant chunks, and retrieve complete documents.
- Persist state: Optionally store thread checkpoints, application-managed memory, and virtual files in Oracle AI Database.
- Invoke or stream: Run the compiled graph with LangGraph invocation, asynchronous invocation, or streaming APIs.
Use the same embedding model and vector dimensions when you index documents and when the agent searches them. A mismatch can make search results inaccurate or cause a database error.
Integration Components
Use these components to assemble the integration.
| Component | Package | Role |
|---|---|---|
create_deepagents_agent() |
langchain-oci[deepagents] |
Combines a LangChain chat model, custom tools, Oracle datastores, and upstream Deep Agents features. |
ADB |
langchain-oci |
Adapts an Oracle vector table as a datastore and provides vector and Oracle Text retrieval. |
OracleVS |
langchain-oracledb |
Stores documents, metadata, and embeddings in Oracle AI Database. |
OracleSaver |
langgraph-oracledb |
Persists per-thread LangGraph checkpoints so an agent can resume. |
OracleStore |
langgraph-oracledb |
Stores application-managed namespaced values with optional vector search. |
StoreBackend |
deepagents |
Maps Deep Agents file operations to a LangGraph store such as OracleStore. |
Choose Reasoning and Embedding Models
Use the factory without a model argument to create a ChatOCIGenAI model. Provide an OCI compartment and service region or endpoint, and select an OCI Generative AI model with model_id.
Pass model= to use a prebuilt LangChain chat model from another provider. Pass embedding_model= to use a prebuilt LangChain embedding model from another provider. In this mode, each supplied model owns its own connection and credentials. Oracle AI Database credentials are still required for Oracle retrieval and persistence.
This separation lets an application change the reasoning model or embedding model without replacing its Oracle data, search, checkpoint, memory, or file layers. The embedding model must match the model, vector dimensions, and embedding settings used to index the Oracle vector table.
Resources
- Python Integration: Install the packages, register an Oracle datastore, create an agent, and add durable state.
- Companion Research Agent Notebook: Build an end-to-end research agent with Oracle retrieval, checkpoints, application-managed memory, and files.
- Source: Oracle Integration for Deep Agents: Review the
create_deepagents_agent()implementation and package examples. - LangChain Deep Agents Documentation: Learn about planning, subagents, file systems, and the upstream agent harness.
- Oracle AI Vector Search Documentation: Review Oracle vector storage, indexing, and search capabilities.