-
Notifications
You must be signed in to change notification settings - Fork 105
Add CallSettings properties to DurableAgent for parity with AI SDK Agent #251
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
Draft
Copilot
wants to merge
5
commits into
main
Choose a base branch
from
copilot/port-tool-loop-properties
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+375
−5
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
628c0a0
Initial plan
Copilot e99d331
Add CallSettings properties to DurableAgent
Copilot 17eb501
Update DurableAgent documentation with new properties
Copilot cb5acbd
Strengthen test assertions to verify properties are stored
Copilot 528f3ed
Remove private modifiers from DurableAgent properties
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,193 @@ | ||
| /** | ||
| * Tests for DurableAgent | ||
| * | ||
| * These tests verify that the DurableAgent constructor properly accepts | ||
| * and stores configuration options from the AI SDK Agent class. | ||
| */ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { DurableAgent } from './durable-agent.js'; | ||
|
|
||
| describe('DurableAgent', () => { | ||
| describe('constructor', () => { | ||
| it('should accept basic required options', () => { | ||
| const agent = new DurableAgent({ | ||
| model: 'anthropic/claude-opus', | ||
| tools: {}, | ||
| }); | ||
|
|
||
| expect(agent).toBeDefined(); | ||
| expect(agent.model).toBe('anthropic/claude-opus'); | ||
| expect(agent.tools).toEqual({}); | ||
| }); | ||
|
|
||
| it('should accept system prompt', () => { | ||
| const agent = new DurableAgent({ | ||
| model: 'anthropic/claude-opus', | ||
| tools: {}, | ||
| system: 'You are a helpful assistant.', | ||
| }); | ||
|
|
||
| expect(agent).toBeDefined(); | ||
| expect(agent.system).toBe('You are a helpful assistant.'); | ||
| }); | ||
|
|
||
| it('should accept temperature option', () => { | ||
| const agent = new DurableAgent({ | ||
| model: 'anthropic/claude-opus', | ||
| tools: {}, | ||
| temperature: 0.7, | ||
| }); | ||
|
|
||
| expect(agent).toBeDefined(); | ||
| expect(agent.temperature).toBe(0.7); | ||
| }); | ||
|
|
||
| it('should accept maxOutputTokens option', () => { | ||
| const agent = new DurableAgent({ | ||
| model: 'anthropic/claude-opus', | ||
| tools: {}, | ||
| maxOutputTokens: 1000, | ||
| }); | ||
|
|
||
| expect(agent).toBeDefined(); | ||
| expect(agent.maxOutputTokens).toBe(1000); | ||
| }); | ||
|
|
||
| it('should accept topP option', () => { | ||
| const agent = new DurableAgent({ | ||
| model: 'anthropic/claude-opus', | ||
| tools: {}, | ||
| topP: 0.9, | ||
| }); | ||
|
|
||
| expect(agent).toBeDefined(); | ||
| expect(agent.topP).toBe(0.9); | ||
| }); | ||
|
|
||
| it('should accept topK option', () => { | ||
| const agent = new DurableAgent({ | ||
| model: 'anthropic/claude-opus', | ||
| tools: {}, | ||
| topK: 40, | ||
| }); | ||
|
|
||
| expect(agent).toBeDefined(); | ||
| expect(agent.topK).toBe(40); | ||
| }); | ||
|
|
||
| it('should accept presencePenalty option', () => { | ||
| const agent = new DurableAgent({ | ||
| model: 'anthropic/claude-opus', | ||
| tools: {}, | ||
| presencePenalty: 0.5, | ||
| }); | ||
|
|
||
| expect(agent).toBeDefined(); | ||
| expect(agent.presencePenalty).toBe(0.5); | ||
| }); | ||
|
|
||
| it('should accept frequencyPenalty option', () => { | ||
| const agent = new DurableAgent({ | ||
| model: 'anthropic/claude-opus', | ||
| tools: {}, | ||
| frequencyPenalty: 0.5, | ||
| }); | ||
|
|
||
| expect(agent).toBeDefined(); | ||
| expect(agent.frequencyPenalty).toBe(0.5); | ||
| }); | ||
|
|
||
| it('should accept stopSequences option', () => { | ||
| const agent = new DurableAgent({ | ||
| model: 'anthropic/claude-opus', | ||
| tools: {}, | ||
| stopSequences: ['STOP', 'END'], | ||
| }); | ||
|
|
||
| expect(agent).toBeDefined(); | ||
| expect(agent.stopSequences).toEqual(['STOP', 'END']); | ||
| }); | ||
|
|
||
| it('should accept seed option', () => { | ||
| const agent = new DurableAgent({ | ||
| model: 'anthropic/claude-opus', | ||
| tools: {}, | ||
| seed: 12345, | ||
| }); | ||
|
|
||
| expect(agent).toBeDefined(); | ||
| expect(agent.seed).toBe(12345); | ||
| }); | ||
|
|
||
| it('should accept all options together', () => { | ||
| const agent = new DurableAgent({ | ||
| model: 'anthropic/claude-opus', | ||
| tools: {}, | ||
| system: 'You are a helpful assistant.', | ||
| temperature: 0.7, | ||
| maxOutputTokens: 1000, | ||
| topP: 0.9, | ||
| topK: 40, | ||
| presencePenalty: 0.5, | ||
| frequencyPenalty: 0.3, | ||
| stopSequences: ['STOP', 'END'], | ||
| seed: 12345, | ||
| }); | ||
|
|
||
| expect(agent).toBeDefined(); | ||
| expect(agent.model).toBe('anthropic/claude-opus'); | ||
| expect(agent.system).toBe('You are a helpful assistant.'); | ||
| expect(agent.temperature).toBe(0.7); | ||
| expect(agent.maxOutputTokens).toBe(1000); | ||
| expect(agent.topP).toBe(0.9); | ||
| expect(agent.topK).toBe(40); | ||
| expect(agent.presencePenalty).toBe(0.5); | ||
| expect(agent.frequencyPenalty).toBe(0.3); | ||
| expect(agent.stopSequences).toEqual(['STOP', 'END']); | ||
| expect(agent.seed).toBe(12345); | ||
| }); | ||
|
|
||
| it('should accept tools with proper structure', () => { | ||
| const tools = { | ||
| testTool: { | ||
| description: 'A test tool', | ||
| inputSchema: { | ||
| type: 'object', | ||
| properties: {}, | ||
| }, | ||
| execute: async () => 'result', | ||
| }, | ||
| }; | ||
|
|
||
| const agent = new DurableAgent({ | ||
| model: 'anthropic/claude-opus', | ||
| tools, | ||
| }); | ||
|
|
||
| expect(agent).toBeDefined(); | ||
| expect(agent.tools).toBe(tools); | ||
| }); | ||
| }); | ||
|
|
||
| describe('methods', () => { | ||
| it('should have generate method', () => { | ||
| const agent = new DurableAgent({ | ||
| model: 'anthropic/claude-opus', | ||
| tools: {}, | ||
| }); | ||
|
|
||
| expect(agent.generate).toBeDefined(); | ||
| expect(typeof agent.generate).toBe('function'); | ||
| }); | ||
|
|
||
| it('should have stream method', () => { | ||
| const agent = new DurableAgent({ | ||
| model: 'anthropic/claude-opus', | ||
| tools: {}, | ||
| }); | ||
|
|
||
| expect(agent.stream).toBeDefined(); | ||
| expect(typeof agent.stream).toBe('function'); | ||
| }); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot This (and all similar ones in the rest of the tests) is a weak assertion. Can we test that the relevant property actually exists on the class instance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in cb5acbd. Tests now verify that each property value is correctly stored on the class instance using type assertions (
as any) to access the private properties.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Instead of casting to
any, how about we just drop theprivatestatements on the class definition itself.privatein TS is kind of dumb anyways.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 528f3ed. Removed
privatemodifiers from all DurableAgent properties and updated tests to access properties directly without type assertions.