This document describes the authoring model Fred now wants to standardize.
Short version:
- new agents SHOULD be written in the v2 model
AgentFlowis now legacy maintenance surface- Fred owns runtime lifecycle, execution, inspection, checkpointing, and MCP wiring
- v2 still uses a warm per-
(session, agent)in-memory cache - durable checkpoints complement that cache; they do not replace it
The goal is not to expose LangGraph directly to every agent author. The goal is to expose a stable Fred SDK above the runtime engine. Authoring happens in Fred terms first; runtime execution is delegated later to the appropriate engine such as the LangChain/LangGraph ReAct stack or the deep agent runtime.
Useful reading order:
- current doc status map: DOC_STATUS.md
- current feature surface: FEATURE_MAP.md
- graph runtime maturity and remaining LangGraph usage: GRAPH_RUNTIME_MATURITY_AND_LANGGRAPH_USAGE.md
- explicit v2 trade-offs against middleware/framework-native layering: RUNTIME_VS_LANGCHAIN_MIDDLEWARE.md
Fred now has two authoring worlds:
- legacy:
AgentFlow - current target:
AgentDefinition
For new work, prefer:
ReActAgentDefinitionfor most conversational or tool-using agentsDeepAgentDefinitionwhen you still want a conversational assistant but need a deeper planner/executor than basic ReActGraphAgentDefinitionfor richer deterministic workflows with explicit state and branching
Concrete examples already present in the repo:
agentic_backend/agents/v2/production/basic_react/agent.pyagentic_backend/agents/v2/production/basic_react/profiles/rag_expert.pyagentic_backend/agents/v2/demos/postal_tracking/agent.pyagentic_backend/agents/v2/samples/tutorial_tools/agent.py
Folder intent in agents/v2/:
samples/: copy/paste-ready authoring starters (not catalog-wired by default)demos/: executable demonstrations for runtime capabilitiescandidate/: exploratory agents under active evaluationproduction/: agents intended for real usage
In v2, the author owns the pure declaration of the agent:
- metadata:
agent_id,role,description,tags - editable fields
- execution description:
- ReAct policy
- or graph topology + node handlers
Tool-aware families such as ReAct and Graph additionally own:
- declared Fred tool refs
- optional default MCP servers
The author does not own:
- runtime activation
- MCP session lifecycle
- compiled graph caching
- checkpoint strategy
- session streaming protocol
- inspection endpoint behavior
That belongs to Fred runtime.
Use ReActAgentDefinition when the agent is fundamentally:
- a prompt/policy
- a set of tools
- optional guardrails
- optional approval policy
This is the default path for:
- general assistants
- RAG assistants
- operational assistants
- most tool supervisors
Examples:
Basic ReAct V2RAG Expert V2- profile-based agents such as
custodian,sentinel,georges,log_genius,geo_demo
Profiles are only a convenient initialization layer. They are not a separate runtime model.
Observability note for ReAct in v2:
- ReAct runtime instrumentation is shared and enforced centrally, not left to each agent author.
- The runtime emits a standard model-call span (
v2.react.model,operation=model_call) and shared metadata context for Langfuse filtering. - Compared to legacy v1-style agent-local runtime wiring, this reduces per-agent drift in tracing quality.
Use GraphAgentDefinition when the agent needs:
- typed workflow state
- explicit deterministic branching
- multiple business steps
- richer HITL checkpoints
- structured outputs such as
GeoPartorLinkPart
The important boundary is:
- author describes graph structure and node behavior
- Fred runtime executes it
Authors should not directly manage LangGraph runtime objects in new code. LangGraph remains an implementation engine, not the author-facing SDK.
The canonical safe introspection surface is now inspect.
What inspection gives:
- metadata
- fields
- execution category
- declared tool refs
- a safe preview artifact
What inspection must not do:
- activate MCP
- build remote clients
- compile executable runtime state
One important point is easy to miss:
- v2 still has an in-memory warm agent cache
- v2 also has durable checkpointing
These are not duplicates.
The warm cache is there so a hot conversation can keep reusing the same session-scoped runtime instance without rebuilding everything on every turn.
The durable checkpointer is there so runtime continuity can survive things the warm cache cannot survive, such as:
- backend restart
- runtime rebuild
- HITL pause/resume
- future non-WebSocket execution adapters
So the current v2 model is:
- cache = performance and hot-session continuity
- checkpointing = durable runtime continuity
This is especially relevant for ReAct agents, where durable checkpointing may add some latency on the happy path even though a warm cached runtime already exists.
For ReAct agents, preview is usually text. For true graph agents, preview may be Mermaid.
For v2 authors, MCP should appear as a platform capability, not as hand-managed client lifecycle.
Current shapes:
- declared Fred tool refs through
declared_tool_refs - attached MCP tool providers through
default_mcp_serversand Fred runtime/tool provider - local Python
@tool(...)authoring, which Fred turns into declared tool refs automatically - built-in v2 tools such as:
knowledge.searchlogs.querytraces.summarize_conversationgeo.render_pointsartifacts.publish_textresources.fetch_text
Short meaning of the native built-ins:
knowledge.search: native Fred RAG retrieval against current libraries, corpus, and attachmentslogs.query: recent backend log triagetraces.summarize_conversation: recent conversation trace summarygeo.render_points: return a rendered map payload from pointsartifacts.publish_text: create a downloadable text artifactresources.fetch_text: load a Fred-managed text resource by key and scopetraces.summarize_conversation
The important rule is:
- declare what the agent needs
- let Fred bind how the tools are actually provided
Runtime intent:
- the authoring contract has two input paths for tools:
- declared Fred tool refs
- attached MCP servers
- local
@tool(...)authoring is only a convenience path that produces declared Fred tool refs - the model should still see one final runtime tool surface
More precisely:
- tool-aware agent families should declare a stable business capability such as
knowledge.search - tool-aware agent families should not hard-code a specific MCP endpoint or server id when Fred already exposes that capability through a first-class tool ref
- MCP server ids and endpoint wiring are platform/infrastructure concerns, not the primary authoring contract for product agents
Example:
- prefer
ToolRefRequirement(tool_ref="knowledge.search") - do not make the agent definition depend directly on
mcp-knowledge-flow-mcp-textjust to perform standard corpus retrieval
Rule of thumb:
- if Fred already exposes a business tool ref, use it
- if a needed capability exists only behind raw MCP and this starts recurring across agents, treat that as pressure to elevate a new Fred capability rather than copying transport details into each agent
Note:
- a first-class Fred tool ref is not automatically MCP-backed
traces.summarize_conversationis implemented through Langfuse Public API calls, not through MCP
For a practical retest checklist of the current v2 world, see FEATURE_MAP.md.
Two v2 capability families are important:
- execution control:
- tool approval
- richer workflow HITL in graph runtimes
- managed resources:
- fetch an admin-provided template or style guide through the v2 resource reader
- publish a generated file through the v2 artifact publisher
- structured outputs:
LinkPartGeoPart- sources/citations
These are platform capabilities. They should not be rebuilt ad hoc inside every agent.
Important clarification:
- in Fred v2, HITL is not limited to "choose one option among N"
- HITL also covers pauses where the runtime expects a free-text human reply, for example a clarification request in a workflow
- the common platform contract is: the runtime pauses, emits
awaiting_human, persists a checkpoint, then resumes with an explicit human payload
When looking at an existing legacy agent, the usual decision tree is:
-
Is it mainly prompt + tools + optional approval? Then it is probably a
ReActAgentDefinition. -
Is it a real multi-step business workflow with typed state? Then it is probably a
GraphAgentDefinition. -
Is it only a tutorial or prototype? Then it probably should not survive as a product agent.
AgentFlow is still present because Fred still has legacy agents in production.
That does not make it the target authoring model.
Use AgentFlow only when:
- maintaining a legacy agent that has not been ported yet
- debugging historical behavior during migration
Do not choose AgentFlow for new product work unless there is a very explicit platform reason.
Legacy v1-oriented guides are grouped in:
docs/deprecated/v1/
docs/AGENT_SPECIFICATION.mddocs/GRAPH_RUNTIME_CONTRACT.mddocs/GRAPH_RUNTIME_CONTRACT.md(see especially the section on conversation history vs runtime checkpoints)docs/RUNTIME_VS_LANGCHAIN_MIDDLEWARE.mddocs/RUNTIME_ARCHITECTURE.mddocs/GENAI_SDK_SPEC.mddocs/GENAI_SDK_COMPATIBILITY_CHALLENGE.md