Constructors and execution
Create an agent and choose its invocation methods.
Managed constructors
Use create_agent for LangChain or create_deep_agent for Deep Agents. Pass your model and tools directly. Pass the OpenEight configuration as openeight=.
Supply your model, tools and provider credentials. The model can be a BaseChatModel or a provider:model string.
from openeight.langchain import create_agent
agent = create_agent(
model=model, tools=tools, openeight=openeight_config,
)
result = agent.invoke(inputs)Expected result · Invocation publishes tools automatically and settles SDK resources when it finishes.
Execution methods
Use invoke/ainvoke for one input or batch/abatch for several. These calls manage sessions automatically. Streaming requires an explicit managed context. If you stop reading a stream early, close it before leaving the session so the SDK can finish work it has already accepted.
Invoke and batch manage sessions automatically. Streaming requires an explicit managed context.
result = agent.invoke(inputs)
print(agent.delivery_status())# Ordinary batch calls manage a temporary session automatically.
results = agent.batch([{ "messages": [("user", "Hello")] },
{ "messages": [("user", "Hello again")] }])
print(agent.delivery_status())
Expected result · Each invocation or batch input gets its own Run. Exhaust or close streams when leaving early. Do not overlap synchronous operations on one entered agent.
Ordinary invoke and batch calls manage their sessions and cleanup automatically. For streaming or a long-lived session, use with or async with and let context exit release owned resources. Explicit flush and close methods are available for applications that manage lifecycle directly.
| Operation | Sync | Async |
|---|---|---|
| Manage sessions across calls → | with | async with |
| Invoke | invoke | await ainvoke |
| Batch | batch | await abatch |
| Stream results and clean up → | stream | astream |
| Flush | flush | await aflush |
| Close | close | await aclose |