Documentation
¶
Overview ¶
Package exec 是轮次执行内核:ExecuteRound 主链(query → receive → map → persist → emit)。
L2 | 父级: internal/runtime(L1 见 AGENTS.md)
成员清单:
- round.go:ExecuteRound 阶段编排与单轮接收状态。
- model.go:RoundExecutionRequest/Result、RoundMapper、RoundMapResult、ErrRoundInterrupted。
- stream_diagnostics.go / stream_error.go:流停止诊断、流关闭与空闲超时错误。
- terminal.go:终态判定与终态结果构造。
- util.go:轮次内容、空闲计时与中断辅助。
- aliases.go:复用 runtime 的 Client / ContextualInputBlock 类型别名。
exec 单向依赖 runtime 核心(Client、ContextualInputBlock、若干导出函数)与 trace; runtime 核心不反向依赖 exec。
[PROTOCOL]: 变更时更新此头部,然后检查父级入口 AGENTS.md(L1)
Index ¶
- Variables
- func RoundStreamStopDiagnosticLogFields(diagnostics RoundStreamStopDiagnostics) []any
- type Client
- type ContextualInputBlock
- type RoundExecutionRequest
- type RoundExecutionResult
- type RoundMapResult
- type RoundMapper
- type RoundStreamClosedError
- type RoundStreamIdleTimeoutError
- type RoundStreamStopDiagnostics
Constants ¶
This section is empty.
Variables ¶
var ( // ErrRoundInterrupted 表示 round 在收到终态前被中断。 ErrRoundInterrupted = errors.New("round interrupted") // ErrRoundStreamClosedBeforeTerminal 表示 SDK 在产出终态前提前结束消息流。 ErrRoundStreamClosedBeforeTerminal = errors.New("round stream closed before terminal") // ErrRoundStreamIdleTimeout 表示 SDK 消息流长时间无新事件且未结束。 ErrRoundStreamIdleTimeout = errors.New("round stream idle timeout") )
Functions ¶
func RoundStreamStopDiagnosticLogFields ¶
func RoundStreamStopDiagnosticLogFields(diagnostics RoundStreamStopDiagnostics) []any
RoundStreamStopDiagnosticLogFields 返回 message_stop 诊断日志字段。
Types ¶
type Client ¶
type Client = runtimectx.Client
exec 复用 runtime 定义的这两个类型:Client 是 round 执行所操作的最小 SDK 能力, ContextualInputBlock 是 runtime 拥有、注入到本轮的隐藏上下文。用类型别名桥接, 避免把这两个横跨 runtime/exec 的类型强行搬家或双向依赖。
type ContextualInputBlock ¶
type ContextualInputBlock = runtimectx.ContextualInputBlock
exec 复用 runtime 定义的这两个类型:Client 是 round 执行所操作的最小 SDK 能力, ContextualInputBlock 是 runtime 拥有、注入到本轮的隐藏上下文。用类型别名桥接, 避免把这两个横跨 runtime/exec 的类型强行搬家或双向依赖。
type RoundExecutionRequest ¶
type RoundExecutionRequest struct {
Query string
Content any
ContextualInputs []ContextualInputBlock
InputOptions sdkprotocol.OutboundMessageOptions
Client Client
Mapper RoundMapper
IdleTimeout time.Duration
InterruptReason func() string
AssistantTerminalGrace time.Duration
SyncSessionID func(string) error
AfterQuery func() error
HandleDurableMessage func(protocol.Message) error
EmitEvent func(protocol.EventMessage) error
ObserveIncomingMessage func(sdkprotocol.ReceivedMessage)
}
RoundExecutionRequest 表示执行单轮查询所需的回调与依赖。
type RoundExecutionResult ¶
type RoundExecutionResult struct {
TerminalStatus string
ResultSubtype string
ErrorMessage string
TerminalCategory sdkprotocol.TerminalCategory
Usage sdkprotocol.TokenUsage
ElapsedTimeSeconds int64
CompletedByAssistant bool
UsageLimitReached bool
UsageLimitReason string
}
RoundExecutionResult 表示 round 执行的终态结果。
func ExecuteRound ¶
func ExecuteRound( ctx context.Context, request RoundExecutionRequest, ) (RoundExecutionResult, error)
ExecuteRound 统一执行 query -> receive -> map -> persist -> emit 的主链路。
type RoundMapResult ¶
type RoundMapResult struct {
Events []protocol.EventMessage
DurableMessages []protocol.Message
TerminalStatus string
ResultSubtype string
}
RoundMapResult 表示单条 SDK 消息映射后的统一结果。
type RoundMapper ¶
type RoundMapper interface {
Map(sdkprotocol.ReceivedMessage, ...string) (RoundMapResult, error)
SessionID() string
}
RoundMapper 负责把 SDK 消息映射成统一事件与 durable 消息。
type RoundStreamClosedError ¶
type RoundStreamClosedError struct {
MessagesSeen int
LastMessageType string
LastMessageSummary string
LastSessionID string
LastMessageID string
ReadError string
WaitError string
LastStreamStop RoundStreamStopDiagnostics
}
RoundStreamClosedError 携带 SDK 流提前关闭时的定位信息。
func (*RoundStreamClosedError) Error ¶
func (e *RoundStreamClosedError) Error() string
func (*RoundStreamClosedError) Unwrap ¶
func (e *RoundStreamClosedError) Unwrap() error
type RoundStreamIdleTimeoutError ¶
type RoundStreamIdleTimeoutError struct {
IdleTimeout time.Duration
MessagesSeen int
LastMessageType string
LastMessageSummary string
LastSessionID string
LastMessageID string
LastStreamStop RoundStreamStopDiagnostics
}
RoundStreamIdleTimeoutError 携带 SDK 流空闲超时时的定位信息。
func (*RoundStreamIdleTimeoutError) Error ¶
func (e *RoundStreamIdleTimeoutError) Error() string
func (*RoundStreamIdleTimeoutError) Unwrap ¶
func (e *RoundStreamIdleTimeoutError) Unwrap() error
type RoundStreamStopDiagnostics ¶
type RoundStreamStopDiagnostics struct {
Observed bool
MessageIndex int
MessagesAfter int
ConversationMessagesAfter int
ProgressMessagesAfter int
PassiveMessagesAfter int
UnknownMessagesAfter int
Age time.Duration
Summary string
StopReason string
SessionID string
MessageID string
Model string
}
RoundStreamStopDiagnostics 表示最近一次 provider message_stop 的定位信息。