Skip to content

Commit 63a1c93

Browse files
authored
add invocation section to langchain/agents guide (langchain-ai#893)
1 parent 22b5dac commit 63a1c93

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

src/oss/langchain/agents.mdx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,29 @@ const result = await agent.invoke(
529529
For more details on message types and formatting, see [Messages](/oss/langchain/messages). For comprehensive middleware documentation, see [Middleware](/oss/langchain/middleware).
530530
</Tip>
531531

532+
## Invocation
533+
534+
You can invoke an agent by passing an update to its [state](/oss/langgraph/graph-api#state). All agents include a [sequence of messages](/oss/langgraph/use-graph-api#messagesstate) in their state; to invoke the agent, pass a new message:
535+
536+
:::python
537+
```python
538+
result = agent.invoke(
539+
{"messages": [{"role": "user", "content": "What's the weather in San Francisco?"}]}
540+
)
541+
```
542+
:::
543+
:::js
544+
```typescript
545+
await agent.invoke({
546+
messages: [{ role: "user", content: "What's the weather in San Francisco?" }],
547+
})
548+
```
549+
:::
550+
551+
For streaming steps and / or tokens from the agent, refer to the [streaming](/oss/langchain/streaming) guide.
552+
553+
Otherwise, the agent follows the LangGraph [Graph API](/oss/langgraph/use-graph-api) and supports all associated methods.
554+
532555
## Advanced concepts
533556

534557
### Structured output

0 commit comments

Comments
 (0)