]> git.giacomolli.uk - onechat/blobdiff - agent.go
Version the package and command from the commit
[onechat] / agent.go
index 1be2b0a136f54dbfa55573ce4b37e572f9798191..0d97cdf4af176d51fcde931e38d7288f003be1ca 100644 (file)
--- a/agent.go
+++ b/agent.go
@@ -50,6 +50,7 @@ func openAgent(dir string) (*Agent, error) {
 
        decoder := json.NewDecoder(bytes.NewReader(data))
        decoder.DisallowUnknownFields()
 
        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")
        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 {
 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
 }
 
 // SubagentPrompt returns the system prompt of a subagent of the agent, with the