-
Notifications
You must be signed in to change notification settings - Fork 4
Feature/sampling agent #9
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
Conversation
- Updated `imitate-tool-use.middleware.ts` to import Tool from the correct path. - Introduced new sampling execution prompts in `index.ts` for agentic reasoning and workflow execution. - Added `sampling` option in `set-up-mcp-compose.ts` to enable sampling-based execution. - Modified types in `types.ts` to include sampling parameters for tool and workflow registration. - Created `tool-tag-processor.ts` to process tool tags in descriptions and replace them with action tags. - Removed deprecated Wecom utility functions from `wecom.ts`. - Implemented new files for agentic and sampling executors, including `agentic-executor.ts`, `agentic-sampling-executor.ts`, and others for workflow management. - Refactored workflow registration and execution logic to support new sampling features.
… and code structure for improved maintainability
…nd maintainability; enhance argument handling and logging
…low execution logic for improved clarity
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.
Pull Request Overview
This PR introduces a comprehensive sampling-based autonomous execution capability to the MCPC (Model Context Protocol Composer) framework. The main purpose is to enable AI agents to execute tasks autonomously through iterative sampling using LLM responses in JSON format.
Key changes include:
- Sampling execution framework: New base classes and executors for autonomous task execution
- Enhanced workflow capabilities: Extended workflow system to support sampling mode with JSON-based interactions
- Refactored architecture: Reorganized code into cleaner executor/factory patterns with better separation of concerns
Reviewed Changes
Copilot reviewed 38 out of 52 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/executors/sampling/*.ts | Core sampling execution framework with base classes and workflow integration |
| packages/core/src/executors/agentic/*.ts | Refactored agentic execution logic into dedicated executor classes |
| packages/core/src/executors/workflow/*.ts | Moved and enhanced workflow execution with sampling support |
| packages/core/src/factories/args-def-factory.ts | Consolidated argument definition factory with sampling schema support |
| packages/core/src/utils/common/tool-tag-processor.ts | New utility for processing tool tags in descriptions |
| packages/core/src/prompts/index.ts | Enhanced prompts with sampling-specific system prompts and instructions |
| packages/core/src/types.ts | Extended type definitions to support sampling mode |
| packages/core/examples/sampling/01-basic-composition.ts | New example demonstrating sampling capabilities |
| allErrors: true, | ||
| verbose: true, | ||
| }); | ||
| // @ts-ignore - |
Copilot
AI
Aug 9, 2025
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.
Using @ts-ignore suppresses TypeScript errors without explanation. Consider using @ts-expect-error with a descriptive comment explaining why the error is expected, or better yet, fix the underlying type issue.
| // @ts-ignore - | |
| // @ts-expect-error ajv-formats types are not fully compatible with Ajv v8 instance, but this is safe at runtime. |
| allErrors: true, | ||
| verbose: true, | ||
| }); | ||
| // @ts-ignore - |
Copilot
AI
Aug 9, 2025
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.
Using @ts-ignore suppresses TypeScript errors without explanation. Consider using @ts-expect-error with a descriptive comment explaining why the error is expected, or better yet, fix the underlying type issue.
| // @ts-ignore - | |
| // @ts-expect-error ajv-formats type definitions are not compatible with Ajv v8 instance; this is safe as per ajv-formats documentation. |
| allErrors: true, | ||
| verbose: true, | ||
| }); | ||
| // @ts-ignore - |
Copilot
AI
Aug 9, 2025
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.
Using @ts-ignore suppresses TypeScript errors without explanation. Consider using @ts-expect-error with a descriptive comment explaining why the error is expected, or better yet, fix the underlying type issue.
| // @ts-ignore - | |
| // @ts-expect-error ajv-formats type definitions are sometimes incompatible with Ajv instance due to version/type mismatches. This is safe at runtime. |
|
|
||
| export abstract class BaseSamplingExecutor { | ||
| protected conversationHistory: ConversationMessage[] = []; | ||
| protected maxIterations: number = 33; |
Copilot
AI
Aug 9, 2025
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.
The magic number 33 for maxIterations lacks explanation. Consider defining this as a named constant with a comment explaining why this specific value was chosen, or make it configurable through the SamplingConfig.
| protected maxIterations: number = 33; | |
| protected maxIterations: number = DEFAULT_MAX_ITERATIONS; |
| const response = await this.server.createMessage({ | ||
| systemPrompt: systemPrompt(), | ||
| messages: this.conversationHistory, | ||
| maxTokens: Number.MAX_SAFE_INTEGER, |
Copilot
AI
Aug 9, 2025
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.
Using Number.MAX_SAFE_INTEGER for maxTokens could lead to extremely large and expensive API calls. Consider setting a reasonable default limit or making this configurable through SamplingConfig.
| maxTokens: Number.MAX_SAFE_INTEGER, | |
| maxTokens: this.maxTokens, |
…stency; refactor code formatting and enhance documentation
eea3764 to
6a24c1e
Compare
…sed LLM service files for improved maintainability
… OS matrix for improved clarity
No description provided.