agentruncontext

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoPendingSessionMessages = errors.New("no pending session messages")

Functions

func ApplyInvokedSkills

func ApplyInvokedSkills(ctx context.Context, req *agentrundomain.RunRequest) error

ApplyInvokedSkills parses leading /skill tokens from user messages, loads matching SKILL.md content, strips the tokens, and rewrites message content.

func CloneRequest

CloneRequest 深拷贝一份 RequestContext,防止 Prepare 过程污染原始请求。

func TruncateForPrompt

func TruncateForPrompt(value string, limit int) string

TruncateForPrompt 将字符串截断到指定长度,超长时追加截断标记。

Types

type ContextBuilder

type ContextBuilder struct {
	SessionMessages SessionMessageProvider
	Memory          MemoryReader
}

ContextBuilder 统一为内部 Agent 和外部 CLI 构建运行上下文。

func NewContextBuilder

func NewContextBuilder(cfg ContextBuilder) *ContextBuilder

NewContextBuilder 创建统一上下文构建器。

func (*ContextBuilder) BuildSystemPrompt

func (b *ContextBuilder) BuildSystemPrompt(ctx context.Context, req *agentrundomain.RunRequest) (string, error)

BuildSystemPrompt 生成统一系统提示词,供所有运行时复用。

func (*ContextBuilder) Prepare

Prepare 克隆请求并注入 memory、skill、session 上下文。

type MemoryReader

type MemoryReader interface {
	BuildPromptBlock(ctx context.Context) (string, error)
}

MemoryReader provides the persisted memory prompt block.

type PassthroughSessionMessageProvider

type PassthroughSessionMessageProvider struct{}

PassthroughSessionMessageProvider 无 DB 依赖的会话消息提供器。 不加载历史上下文,不占位消息,仅校验输入是否为空来决定是否跳过执行。

func (*PassthroughSessionMessageProvider) CompleteClaimed

CompleteClaimed 不需要做任何事。Worker 完成结果通过 NATS 事件通知 Server 侧 runnable 写入 DB。

func (*PassthroughSessionMessageProvider) Prepare

Prepare 校验是否有待处理的用户输入。有则放行,无则返回 ErrNoPendingSessionMessages 让 pipeline 跳过。

type SessionMessageProvider

type SessionMessageProvider interface {
	// Prepare 构建历史上下文、占位本轮待处理用户消息,并填充运行输入。
	Prepare(ctx context.Context, req *agentrundomain.RunRequest) error
	// CompleteClaimed 将本轮已占位的用户消息标记为已处理。
	CompleteClaimed(ctx context.Context, req *agentrundomain.RunRequest) error
}

SessionMessageProvider 将持久化的会话消息注入到 Agent 运行上下文中。

func NewPassthroughSessionMessageProvider

func NewPassthroughSessionMessageProvider() SessionMessageProvider

NewPassthroughSessionMessageProvider 创建无 DB 依赖的会话消息提供器。

Jump to

Keyboard shortcuts

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