Skip to content

Agents docs #271

Draft
pavelgj wants to merge 17 commits into
mainfrom
pj/agents-docs
Draft

Agents docs #271
pavelgj wants to merge 17 commits into
mainfrom
pj/agents-docs

Conversation

@pavelgj

@pavelgj pavelgj commented May 8, 2026

Copy link
Copy Markdown
Member

pavelgj added 2 commits May 8, 2026 16:01
- Rewrite agents intro to highlight middleware support and be more concise
- Add cross-link tip from agentic-patterns page to new agents page
- Replace TypeScript interface examples with Zod schema-based state
- Add "State management strategies" section for session state patterns
- Improve beta import note formatting with callout block

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the new Agents API (Beta) documentation, replacing the deprecated ai.chat() and legacy multi-agent patterns. It adds a comprehensive guide covering agent definition, state management, persistence, and multi-agent delegation. Review feedback highlights a runtime error in a custom agent example, suggests updating outdated model references to Gemini 2.0, and recommends defining a missing type in a code snippet for better clarity.

Comment thread src/content/docs/docs/agents.mdx Outdated
Comment thread src/content/docs/docs/agents.mdx
Comment thread src/content/docs/docs/agents.mdx Outdated
Comment thread src/content/docs/docs/agents.mdx
Comment thread src/content/docs/docs/multi-agent.mdx
pavelgj added 4 commits May 8, 2026 17:00
- Reword page description and intro to focus on app-level use cases
  (chatbots, approval flows, generators) instead of internals
- Fix incorrect `sess.session.addMessages()` → `sess.addMessages()`
- Add paragraph explaining agents as standard HTTP endpoints
- Enhance custom state section framing and add client-side code example
Capitalize "agents" to "Agents" in the introductory sentence for consistent branding with the rest of the documentation.

@i14h i14h left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks. Great doc, a few feedbacks reading as a noob person

Comment thread src/content/docs/docs/agents.mdx Outdated
Comment thread src/content/docs/docs/agents.mdx Outdated
Comment thread src/content/docs/docs/agents.mdx Outdated
Comment thread src/content/docs/docs/agents.mdx
Comment thread src/content/docs/docs/agents.mdx Outdated
Comment thread src/content/docs/docs/agents.mdx Outdated
Comment thread src/content/docs/docs/agents.mdx Outdated

For long-running tasks (report generation, deep research), run the agent
in the background. The client submits a request, receives a `snapshotId`
immediately, and polls for the result.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: continue with "To implement background execution, you need to make changes on the server and client:"

Comment thread src/content/docs/docs/agents.mdx Outdated
## Multi-agent delegation

Use the `agents()` middleware from `@genkit-ai/middleware` to let an
orchestrator agent delegate tasks to specialized sub-agents.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same nit as before.

Comment thread src/content/docs/docs/agents.mdx Outdated
`agent.streamBidi()` creates a bidirectional streaming session - you can send
messages and receive streamed responses concurrently. This is useful for
server-side scripts or advanced scenarios where you need to queue multiple
messages before reading responses:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

it's great that you explain the utility, but I don't quite understand the examples you mention. Why server-side scripts would need this? or why would I need to queue multiple messages?

```ts
const session = weatherAgent.streamBidi({ snapshotId: previousSnapshotId });
```

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe also a section for subagents using middleware?

pavelgj added 8 commits May 8, 2026 19:20
Expand documentation for defineAgent, definePromptAgent, and
defineCustomAgent with more detailed descriptions, use-case bullet
points, and inline code comments to help readers understand when
and why to use each agent type.
Replaces the single interrupt example with two clearly separated
patterns (resume.respond and resume.restart), adds a comparison
table, and provides distinct server/client examples for each.
Highlights security benefits of the restart pattern for
approval-gated tools.
Revise the Agents documentation to reflect the unified API where
server and client agents expose the same interface. Update import
paths to include `genkit/beta/client`, make the `model` parameter
optional (defaulting to the `genkit()` config), and clarify that
custom status is streamed by mutating session state.
Add a quick-reference guide for the three ag
Change prompt example code fence from `none` to `handlebars` for proper
syntax highlighting, and remove accidentally committed task progress
metadata at the end of the file.
Expand the explanation of the agent server endpoints to distinguish the
required primary endpoint from the optional snapshot and abort endpoints.
Clarify that the snapshot endpoint applies only to server-managed agents
with a store, and the abort endpoint only to background execution.
@cabljac

cabljac commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

I feel like i'd like to see an e2e example earlier on? at the moment i have to scroll past defineAgent, definePromptAgent, defineCustomAgent - the first e2e example is "Multi-turn streaming chat" right, maybe that could be moved earlier

Update the agents guide to document `session.getCustom()` for reading state
and `session.updateCustom()` for mutating it, with a new listTasks tool
example. Improve state normalization to default per-field for fresh
sessions, import `z` in the setup snippet, and clarify that
`getSnapshotDataAction` and `abortAgentAction` are server-side agent
properties rather than part of the shared `AgentAPI`.
@cabljac

cabljac commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

SessionStore<S> is exported but we could document or hint at how to create a custom store?

[Session persistence](#session-persistence) for detailed examples of each
strategy, including session restoration, branching, and pruning.

## Testing agents in the developer UI

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This should have more details about the actual specific places where you can interact with agents in the DevUI.

pavelgj added 2 commits June 16, 2026 15:22
Rewrite the agents documentation to follow a progressive disclosure
approach. Replace the abstract unified-API introduction with a simpler
explanation, and add "Your first agent" and "Add tools and serve over
HTTP" sections that build incrementally from minimal to capable agents.
Include links to advanced topics so readers can add capabilities as
needed.
Streamline the agents page introduction for clarity and add a note
explaining the interchangeable model reference syntax. Remove the
ai.defineCustomAgent() documentation section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants