fix: resolve lint errors for PR #2781
Fix gci import grouping, golines long line, and misspell (behaviours → behaviors). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
cb176e16ff
commit
c0bc4624be
3 changed files with 22 additions and 22 deletions
|
|
@ -22,12 +22,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type ContextBuilder struct {
|
type ContextBuilder struct {
|
||||||
workspace string
|
workspace string
|
||||||
skillsLoader *skills.SkillsLoader
|
skillsLoader *skills.SkillsLoader
|
||||||
memory *MemoryStore
|
memory *MemoryStore
|
||||||
splitOnMarker bool
|
splitOnMarker bool
|
||||||
skillCatalogCfg config.SkillCatalogConfig
|
skillCatalogCfg config.SkillCatalogConfig
|
||||||
promptRegistry *PromptRegistry
|
promptRegistry *PromptRegistry
|
||||||
|
|
||||||
// Cache for system prompt to avoid rebuilding on every call.
|
// Cache for system prompt to avoid rebuilding on every call.
|
||||||
// This fixes issue #607: repeated reprocessing of the entire context.
|
// This fixes issue #607: repeated reprocessing of the entire context.
|
||||||
|
|
@ -208,7 +208,6 @@ func (cb *ContextBuilder) BuildSystemPromptParts() []PromptPart {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Memory context
|
// Memory context
|
||||||
memoryContext := cb.memory.GetMemoryContext()
|
memoryContext := cb.memory.GetMemoryContext()
|
||||||
if memoryContext != "" {
|
if memoryContext != "" {
|
||||||
|
|
@ -306,7 +305,7 @@ func (cb *ContextBuilder) EstimateSystemTokens(summary string, activeSkills []st
|
||||||
// (EstimateSystemTokens assumes a non-continuation turn).
|
// (EstimateSystemTokens assumes a non-continuation turn).
|
||||||
if skillsSummary := cb.skillsLoader.BuildSkillsSummary(); skillsSummary != "" {
|
if skillsSummary := cb.skillsLoader.BuildSkillsSummary(); skillsSummary != "" {
|
||||||
totalChars += utf8.RuneCountInString(skillsSummary) + 80 // header overhead
|
totalChars += utf8.RuneCountInString(skillsSummary) + 80 // header overhead
|
||||||
totalChars += 7 // separator
|
totalChars += 7 // separator
|
||||||
}
|
}
|
||||||
|
|
||||||
if skillsText := cb.buildActiveSkillsContext(activeSkills); skillsText != "" {
|
if skillsText := cb.buildActiveSkillsContext(activeSkills); skillsText != "" {
|
||||||
|
|
@ -697,23 +696,24 @@ func (cb *ContextBuilder) BuildMessagesFromPrompt(req PromptBuildRequest) []prov
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine whether to inject the skill catalog.
|
// Determine whether to inject the skill catalog.
|
||||||
// Both skip behaviours are opt-in via config (default: always include).
|
// Both skip behaviors are opt-in via config (default: always include).
|
||||||
isToolContinuation := len(req.History) > 0 && req.History[len(req.History)-1].Role == "tool"
|
isToolContinuation := len(req.History) > 0 && req.History[len(req.History)-1].Role == "tool"
|
||||||
isFirstTurn := len(req.History) == 0
|
isFirstTurn := len(req.History) == 0
|
||||||
isAfterCompaction := req.Summary != ""
|
isAfterCompaction := req.Summary != ""
|
||||||
skipForTools := cb.skillCatalogCfg.SkipOnTools && isToolContinuation
|
skipForTools := cb.skillCatalogCfg.SkipOnTools && isToolContinuation
|
||||||
skipForSubsequent := cb.skillCatalogCfg.SkipOnSubsequent && !isFirstTurn && !isAfterCompaction && !isToolContinuation
|
skipForSubsequent := cb.skillCatalogCfg.SkipOnSubsequent &&
|
||||||
|
!isFirstTurn && !isAfterCompaction && !isToolContinuation
|
||||||
if !skipForTools && !skipForSubsequent {
|
if !skipForTools && !skipForSubsequent {
|
||||||
if skillsSummary := cb.skillsLoader.BuildSkillsSummary(); skillsSummary != "" {
|
if skillsSummary := cb.skillsLoader.BuildSkillsSummary(); skillsSummary != "" {
|
||||||
catalogPart := PromptPart{
|
catalogPart := PromptPart{
|
||||||
ID: "capability.skill_catalog",
|
ID: "capability.skill_catalog",
|
||||||
Layer: PromptLayerCapability,
|
Layer: PromptLayerCapability,
|
||||||
Slot: PromptSlotSkillCatalog,
|
Slot: PromptSlotSkillCatalog,
|
||||||
Source: PromptSource{ID: PromptSourceSkillCatalog, Name: "skill:index"},
|
Source: PromptSource{ID: PromptSourceSkillCatalog, Name: "skill:index"},
|
||||||
Title: "skill catalog",
|
Title: "skill catalog",
|
||||||
Content: fmt.Sprintf("# Skills\n\nThe following skills extend your capabilities. To use a skill, read its SKILL.md file using the read_file tool.\n\n%s", skillsSummary),
|
Content: fmt.Sprintf("# Skills\n\nThe following skills extend your capabilities. To use a skill, read its SKILL.md file using the read_file tool.\n\n%s", skillsSummary),
|
||||||
Stable: true,
|
Stable: true,
|
||||||
Cache: PromptCacheEphemeral,
|
Cache: PromptCacheEphemeral,
|
||||||
}
|
}
|
||||||
stringParts = append(stringParts, catalogPart.Content)
|
stringParts = append(stringParts, catalogPart.Content)
|
||||||
contentBlocks = append(contentBlocks, promptContentBlock(catalogPart, &providers.CacheControl{Type: "ephemeral"}))
|
contentBlocks = append(contentBlocks, promptContentBlock(catalogPart, &providers.CacheControl{Type: "ephemeral"}))
|
||||||
|
|
|
||||||
|
|
@ -680,8 +680,8 @@ func TestSkillCatalogInjectionPolicy(t *testing.T) {
|
||||||
t.Error("turn > 1, no summary: catalog should be skipped")
|
t.Error("turn > 1, no summary: catalog should be skipped")
|
||||||
}
|
}
|
||||||
if !contains(cb.BuildMessagesFromPrompt(PromptBuildRequest{
|
if !contains(cb.BuildMessagesFromPrompt(PromptBuildRequest{
|
||||||
History: []providers.Message{userMsg, assistantMsg},
|
History: []providers.Message{userMsg, assistantMsg},
|
||||||
Summary: "prior conversation summary",
|
Summary: "prior conversation summary",
|
||||||
})) {
|
})) {
|
||||||
t.Error("after compaction: catalog should be re-injected")
|
t.Error("after compaction: catalog should be re-injected")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -285,9 +285,9 @@ type AgentDefaults struct {
|
||||||
SteeringMode string `json:"steering_mode,omitempty" env:"PICOCLAW_AGENTS_DEFAULTS_STEERING_MODE"` // "one-at-a-time" (default) or "all"
|
SteeringMode string `json:"steering_mode,omitempty" env:"PICOCLAW_AGENTS_DEFAULTS_STEERING_MODE"` // "one-at-a-time" (default) or "all"
|
||||||
MaxParallelTurns int `json:"max_parallel_turns,omitempty" env:"PICOCLAW_AGENTS_DEFAULTS_MAX_PARALLEL_TURNS"` // Max concurrent turns (0 or 1 = sequential)
|
MaxParallelTurns int `json:"max_parallel_turns,omitempty" env:"PICOCLAW_AGENTS_DEFAULTS_MAX_PARALLEL_TURNS"` // Max concurrent turns (0 or 1 = sequential)
|
||||||
SubTurn SubTurnConfig `json:"subturn" envPrefix:"PICOCLAW_AGENTS_DEFAULTS_SUBTURN_"`
|
SubTurn SubTurnConfig `json:"subturn" envPrefix:"PICOCLAW_AGENTS_DEFAULTS_SUBTURN_"`
|
||||||
ToolFeedback ToolFeedbackConfig `json:"tool_feedback,omitempty"`
|
ToolFeedback ToolFeedbackConfig `json:"tool_feedback,omitempty"`
|
||||||
SplitOnMarker bool `json:"split_on_marker" env:"PICOCLAW_AGENTS_DEFAULTS_SPLIT_ON_MARKER"` // split messages on <|[SPLIT]|> marker
|
SplitOnMarker bool `json:"split_on_marker" env:"PICOCLAW_AGENTS_DEFAULTS_SPLIT_ON_MARKER"` // split messages on <|[SPLIT]|> marker
|
||||||
SkillCatalog SkillCatalogConfig `json:"skill_catalog,omitempty"`
|
SkillCatalog SkillCatalogConfig `json:"skill_catalog,omitempty"`
|
||||||
ContextManager string `json:"context_manager,omitempty" env:"PICOCLAW_AGENTS_DEFAULTS_CONTEXT_MANAGER"`
|
ContextManager string `json:"context_manager,omitempty" env:"PICOCLAW_AGENTS_DEFAULTS_CONTEXT_MANAGER"`
|
||||||
ContextManagerConfig json.RawMessage `json:"context_manager_config,omitempty" env:"PICOCLAW_AGENTS_DEFAULTS_CONTEXT_MANAGER_CONFIG"`
|
ContextManagerConfig json.RawMessage `json:"context_manager_config,omitempty" env:"PICOCLAW_AGENTS_DEFAULTS_CONTEXT_MANAGER_CONFIG"`
|
||||||
MaxLLMRetries int `json:"max_llm_retries,omitempty" env:"PICOCLAW_AGENTS_DEFAULTS_MAX_LLM_RETRIES"`
|
MaxLLMRetries int `json:"max_llm_retries,omitempty" env:"PICOCLAW_AGENTS_DEFAULTS_MAX_LLM_RETRIES"`
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue