Skip to content

Conversation

@yaonyan
Copy link
Contributor

@yaonyan yaonyan commented Aug 9, 2025

No description provided.

yaonyan added 4 commits August 5, 2025 11:32
- 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
@yaonyan yaonyan requested a review from Copilot August 9, 2025 13:26
@yaonyan yaonyan self-assigned this Aug 9, 2025
@yaonyan yaonyan added the enhancement New feature or request label Aug 9, 2025
Copy link
Contributor

Copilot AI left a 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 -
Copy link

Copilot AI Aug 9, 2025

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.

Suggested change
// @ts-ignore -
// @ts-expect-error ajv-formats types are not fully compatible with Ajv v8 instance, but this is safe at runtime.

Copilot uses AI. Check for mistakes.
allErrors: true,
verbose: true,
});
// @ts-ignore -
Copy link

Copilot AI Aug 9, 2025

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.

Suggested change
// @ts-ignore -
// @ts-expect-error ajv-formats type definitions are not compatible with Ajv v8 instance; this is safe as per ajv-formats documentation.

Copilot uses AI. Check for mistakes.
allErrors: true,
verbose: true,
});
// @ts-ignore -
Copy link

Copilot AI Aug 9, 2025

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.

Suggested change
// @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.

Copilot uses AI. Check for mistakes.

export abstract class BaseSamplingExecutor {
protected conversationHistory: ConversationMessage[] = [];
protected maxIterations: number = 33;
Copy link

Copilot AI Aug 9, 2025

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.

Suggested change
protected maxIterations: number = 33;
protected maxIterations: number = DEFAULT_MAX_ITERATIONS;

Copilot uses AI. Check for mistakes.
const response = await this.server.createMessage({
systemPrompt: systemPrompt(),
messages: this.conversationHistory,
maxTokens: Number.MAX_SAFE_INTEGER,
Copy link

Copilot AI Aug 9, 2025

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.

Suggested change
maxTokens: Number.MAX_SAFE_INTEGER,
maxTokens: this.maxTokens,

Copilot uses AI. Check for mistakes.
…stency; refactor code formatting and enhance documentation
@yaonyan yaonyan force-pushed the feature/sampling-agent branch from eea3764 to 6a24c1e Compare August 10, 2025 06:16
@yaonyan yaonyan merged commit 544da21 into main Aug 10, 2025
3 checks passed
@yaonyan yaonyan changed the title [WIP]Feature/sampling agent Feature/sampling agent Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants