contextfix

package
v1.3.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package contextfix 在每次 Run 开始时修理消息历史,双向修补: 补缺 —— assistant 的 tool_call 缺少对应 tool 结果时补占位消息; 删孤 —— tool 结果消息对应的 assistant 调用已丢失时删除(保留会被 API 拒绝)。 与引擎收尾段的不变量互补:引擎保证本轮产生的历史完整, 本 hook 保证历史进入引擎前完整(外部注入的残缺历史、旧存档、异常中断等)。

Index

Constants

View Source
const Placeholder = "(missing tool result)"

Placeholder 是缺失结果的占位文案,模型据此得知该调用没有可用的执行结果。

Variables

This section is empty.

Functions

func Fix

func Fix(msgs []types.Message) []types.Message

Fix 双向修理历史;历史完整时原样返回(不新建切片)。

Types

type Hook

type Hook struct{}

func New

func New() *Hook

func (Hook) Name

func (Hook) Name() string

func (Hook) OnStart

func (Hook) OnStart(_ context.Context, state *types.LoopState) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL