Documentation
¶
Index ¶
- Variables
- func ApplyInvokedSkills(ctx context.Context, req *agentrundomain.RunRequest) error
- func CloneRequest(req *agentrundomain.RunRequest) *agentrundomain.RunRequest
- func TruncateForPrompt(value string, limit int) string
- type ContextBuilder
- type MemoryReader
- type PassthroughSessionMessageProvider
- type SessionMessageProvider
Constants ¶
This section is empty.
Variables ¶
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 ¶
func CloneRequest(req *agentrundomain.RunRequest) *agentrundomain.RunRequest
CloneRequest 深拷贝一份 RequestContext,防止 Prepare 过程污染原始请求。
func TruncateForPrompt ¶
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 ¶
func (b *ContextBuilder) Prepare(ctx context.Context, req *agentrundomain.RunRequest) (*agentrundomain.RunRequest, error)
Prepare 克隆请求并注入 memory、skill、session 上下文。
type MemoryReader ¶
MemoryReader provides the persisted memory prompt block.
type PassthroughSessionMessageProvider ¶
type PassthroughSessionMessageProvider struct{}
PassthroughSessionMessageProvider 无 DB 依赖的会话消息提供器。 不加载历史上下文,不占位消息,仅校验输入是否为空来决定是否跳过执行。
func (*PassthroughSessionMessageProvider) CompleteClaimed ¶
func (p *PassthroughSessionMessageProvider) CompleteClaimed(_ context.Context, _ *agentrundomain.RunRequest) error
CompleteClaimed 不需要做任何事。Worker 完成结果通过 NATS 事件通知 Server 侧 runnable 写入 DB。
func (*PassthroughSessionMessageProvider) Prepare ¶
func (p *PassthroughSessionMessageProvider) Prepare(_ context.Context, req *agentrundomain.RunRequest) error
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 依赖的会话消息提供器。