Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: include shared context from context tools referenced by "tools:" #791

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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