mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
# Conflicts: # docs/architecture.md # docs/config-catalog.md # docs/cordis-catalog/services.md # docs/rfc/INDEX.md # packages/cordis/tool-cordis/src/api-catalog.ts # packages/core/agent-loop/README.md # packages/core/agent-loop/src/index.ts # packages/core/agent-loop/src/loop.ts # packages/core/tools/README.md # packages/core/tools/src/index.ts # packages/subagent/subagent/src/types.ts # packages/subagent/tool-subagent/README.md # scripts/gen-cordis-catalog.ts # scripts/type-equiv.manifest.json
55 lines
2.5 KiB
Markdown
55 lines
2.5 KiB
Markdown
<!-- Generated by scripts/gen-doc-graphs.ts - do not edit by hand.
|
|
Run `pnpm run gen-doc-graphs` to regenerate. -->
|
|
|
|
# Agent Turn And Step Lifecycle
|
|
|
|
This sequence is the visual companion to [architecture.md](architecture.md#loop-lifecycle-session--turn--step). It keeps durable replay facts on `session/event` and live control/status on `agent/*`.
|
|
|
|
```mermaid
|
|
sequenceDiagram
|
|
participant User
|
|
participant Agent
|
|
participant Driver
|
|
participant Hooks as hook listeners
|
|
participant Prompt as ctx.systemPrompt
|
|
participant LLM as ctx.llm
|
|
participant Tools as ctx.tools
|
|
participant Session
|
|
participant Persistence
|
|
participant SDK as UI or SDK listener
|
|
User->>Agent: send(content)
|
|
Agent-->>SDK: <code>agent/queued</code>
|
|
Agent->>Driver: queued work wakes driver
|
|
Driver-->>SDK: <code>agent/status</code> running
|
|
Driver->>Session: <code>turn/start</code>
|
|
Driver->>Hooks: <code>agent/prompt-submit</code> waterfall
|
|
Hooks-->>Driver: allow, block, or add context
|
|
Driver->>Session: <code>user/message</code> or rejected <code>turn/end</code>
|
|
Driver->>Prompt: <code>system-prompt/assemble</code> waterfall
|
|
Driver-->>Driver: <code>agent/pre-step</code> serial checkpoint
|
|
Driver->>Session: <code>step/start</code>
|
|
Driver->>LLM: <code>agent/request</code> waterfall, then <code>llm/stream</code> waterfall
|
|
LLM-->>Driver: StreamChunk*
|
|
Driver->>Session: <code>assistant/chunk</code>*
|
|
Session-->>SDK: <code>session/event</code> <code>assistant/chunk</code>*
|
|
Driver->>Hooks: <code>agent/step-result</code> waterfall
|
|
Driver->>Session: <code>assistant/message</code>
|
|
Driver->>Tools: group calls by executionMode
|
|
loop started tool calls (bounded pool)
|
|
Driver->>Session: <code>tool/call</code> pending audit
|
|
Driver->>Tools: ordered pre / pooled dispatch / ordered post
|
|
Tools-->>Session: tool-owned events when applicable
|
|
end
|
|
Driver->>Session: <code>tool/result</code> in model order
|
|
Driver->>Session: <code>step/end</code>
|
|
Driver->>Hooks: <code>agent/turn-continuation</code> waterfall
|
|
Driver->>Hooks: <code>agent/turn-stop</code> serial terminal checkpoint
|
|
Driver->>Session: <code>turn/end</code>
|
|
Driver->>Persistence: <code>session/flush</code> parallel checkpoint
|
|
Driver-->>SDK: <code>agent/status</code> idle
|
|
```
|
|
|
|
SDK users that need replayable transcript data should consume `session/event`; `agent/*` is the live coordination surface for queue/status, prompt interception, request shaping, steering, continuation, and errors.
|
|
|
|
Maintenance mode: curated Mermaid sequence; exact event signatures live in the generated Cordis catalog.
|