Skip to content

Commit

Permalink
Merge pull request #791 from ibuildthecloud/main
Browse files Browse the repository at this point in the history
bug: include shared context from context tools referenced by "tools:"
  • Loading branch information
ibuildthecloud authored Aug 12, 2024
2 parents 75d9600 + 707d483 commit 50503da
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/tests/testdata/TestToolRefAll/call1.golden
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"role": "system",
"content": [
{
"text": "\nContext Body\nMain tool"
"text": "\nShared context\n\nContext Body\nMain tool"
}
],
"usage": {}
Expand Down
8 changes: 8 additions & 0 deletions pkg/tests/testdata/TestToolRefAll/test.gpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,19 @@ Agent body
---
name: context
type: context
share context: sharedcontext

#!sys.echo

Context Body

---
name: sharedcontext

#!sys.echo

Shared context

---
name: none
param: noneArg: stuff
Expand Down
12 changes: 11 additions & 1 deletion pkg/types/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,17 @@ func (t Tool) getExportedTools(prg Program) ([]ToolReference, error) {
func (t Tool) GetContextTools(prg Program) ([]ToolReference, error) {
result := &toolRefSet{}
result.AddAll(t.getDirectContextToolRefs(prg))
result.AddAll(t.getCompletionToolRefs(prg, nil, ToolTypeContext))

contextRefs, err := t.getCompletionToolRefs(prg, nil, ToolTypeContext)
if err != nil {
return nil, err
}

for _, contextRef := range contextRefs {
result.AddAll(prg.ToolSet[contextRef.ToolID].getExportedContext(prg))
result.Add(contextRef)
}

return result.List()
}

Expand Down

0 comments on commit 50503da

Please sign in to comment.