-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(agent): add local workflow skill suggestions #987
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
Closed
Closed
Changes from all commits
Commits
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
73 changes: 73 additions & 0 deletions
73
packages/browseros-agent/apps/agent/lib/workflow-usage/advisor.test.ts
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,73 @@ | ||
| import { describe, expect, it } from 'bun:test' | ||
| import { | ||
| analyzeWorkflowUsage, | ||
| detectWorkflowAdvisorCommand, | ||
| formatWorkflowAnalysisResponse, | ||
| normalizeToolSequence, | ||
| } from './advisor' | ||
| import type { WorkflowUsageRecord } from './types' | ||
|
|
||
| describe('workflow usage advisor', () => { | ||
| it('detects explicit workflow advisor commands only', () => { | ||
| expect(detectWorkflowAdvisorCommand('analyze my workflow')).toBe('analyze') | ||
| expect(detectWorkflowAdvisorCommand('what patterns do you see?')).toBe( | ||
| 'analyze', | ||
| ) | ||
| expect(detectWorkflowAdvisorCommand('show workflow usage data')).toBe( | ||
| 'view', | ||
| ) | ||
| expect(detectWorkflowAdvisorCommand('clear skill suggestion data')).toBe( | ||
| 'clear', | ||
| ) | ||
| expect(detectWorkflowAdvisorCommand('summarize this page')).toBeNull() | ||
| }) | ||
|
|
||
| it('normalizes command sequences without retaining repeated adjacent tools', () => { | ||
| expect(normalizeToolSequence([' new_page ', 'new_page', 'open'])).toEqual([ | ||
| 'new_page', | ||
| 'open', | ||
| ]) | ||
| }) | ||
|
|
||
| it('suggests repeated local tool-name patterns', () => { | ||
| const analysis = analyzeWorkflowUsage([ | ||
| record('1', ['new_page', 'navigate', 'get_page_content'], 100), | ||
| record('2', ['new_page', 'navigate', 'get_page_content'], 200), | ||
| record('3', ['search', 'open'], 300), | ||
| ]) | ||
|
|
||
| expect(analysis.totalRuns).toBe(3) | ||
| expect(analysis.suggestions).toHaveLength(1) | ||
| expect(analysis.suggestions[0]).toMatchObject({ | ||
| runCount: 2, | ||
| pattern: ['new_page', 'navigate', 'get_page_content'], | ||
| }) | ||
| }) | ||
|
|
||
| it('formats concrete suggestions with a privacy note', () => { | ||
| const response = formatWorkflowAnalysisResponse( | ||
| analyzeWorkflowUsage([ | ||
| record('1', ['new_page', 'navigate', 'get_page_content'], 100), | ||
| record('2', ['new_page', 'navigate', 'get_page_content'], 200), | ||
| ]), | ||
| ) | ||
|
|
||
| expect(response).toContain('Pattern: Open page -> Navigate -> Read page') | ||
| expect(response).toContain('Create a "Open Page to Read Page Skill" skill') | ||
| expect(response).toContain('does not include URLs') | ||
| expect(response).toContain('tool inputs') | ||
| }) | ||
| }) | ||
|
|
||
| function record( | ||
| id: string, | ||
| toolNames: string[], | ||
| recordedAt: number, | ||
| ): WorkflowUsageRecord { | ||
| return { | ||
| id, | ||
| source: 'sidepanel-chat', | ||
| recordedAt, | ||
| toolNames, | ||
| } | ||
| } |
Oops, something went wrong.
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.
MESSAGE_SENT_EVENTanalytics fires for locally-handled commandstrack(MESSAGE_SENT_EVENT, ...)executes before thedetectWorkflowAdvisorCommandearly-return check. Workflow advisor commands — which never reach an LLM — are therefore counted as sent messages in analytics, skewing provider/model/agent event data with local-only interactions. Moving thedetectWorkflowAdvisorCommandcheck (or thetrackcall) before the other to ensure the event only fires when a message is genuinely dispatched would fix this.Prompt To Fix With AI