X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/ddd0a50f7b801112376d7fb27bfd05d2fc26c2fd..f226928c3a074ac4856ba07e8fd7107aba5444a3:/agent.go?ds=inline diff --git a/agent.go b/agent.go index 1be2b0a..0d97cdf 100644 --- a/agent.go +++ b/agent.go @@ -50,6 +50,7 @@ func openAgent(dir string) (*Agent, error) { decoder := json.NewDecoder(bytes.NewReader(data)) decoder.DisallowUnknownFields() + err = decoder.Decode(&config) if err == nil && !errors.Is(decoder.Decode(&struct{}{}), io.EOF) { err = errors.New("data after the JSON object") @@ -87,10 +88,15 @@ func (a *Agent) CacheKey() string { func (a *Agent) Prompt() (string, error) { instructions, err := a.instructions() if err != nil { - return "", err + return "", fmt.Errorf("read prompt instructions: %w", err) + } + + path, err := filepath.Abs(filepath.Join(a.dir, agentInstructionsFileName)) + if err != nil { + return "", fmt.Errorf("find instructions path: %w", err) } - return prompt(a.config.Name, instructions), nil + return prompt(a.config.Name, path, instructions), nil } // SubagentPrompt returns the system prompt of a subagent of the agent, with the