-
Notifications
You must be signed in to change notification settings - Fork 44
Transform subAgent tool into agentStart and agentMessage tools #111
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
Comments
Implementation Plan1. Code StructureNew Files to Create
Shared StateCreate a shared state module to track running agents:
2. Implementation DetailsagentState.tsimport { CoreMessage } from 'ai';
import { v4 as uuidv4 } from 'uuid';
import { Tool } from '../../core/types.js';
import { ToolContext } from '../../core/toolAgent/types.js';
// Define AgentState type
export type AgentState = {
instanceId: string;
goal: string;
prompt: string;
tools: Tool[];
context: ToolContext;
messages: CoreMessage[];
status: 'running' | 'paused' | 'completed' | 'error';
result: string;
error?: string;
lastUpdated: number;
};
// Global map to store agent states
export const agentStates: Map<string, AgentState> = new Map();
// Helper to create a new agent instance ID
export const createAgentInstanceId = (): string => {
return uuidv4();
}; agentStart.tsimport { z } from 'zod';
import { zodToJsonSchema } from 'zod-to-json-schema';
import { Tool, ToolContext } from '../../core/types.js';
import { getTools } from '../getTools.js';
import { agentStates, createAgentInstanceId, AgentState } from './agentState.js';
import { getDefaultSystemPrompt, getModel } from '../../core/toolAgent/index.js';
// Similar schema to current subAgent but returns immediately
const parameterSchema = z.object({
description: z
.string()
.describe("A brief description of the sub-agent's purpose (max 80 chars)"),
goal: z
.string()
.describe('The main objective that the sub-agent needs to achieve'),
projectContext: z
.string()
.describe('Context about the problem or environment'),
workingDirectory: z
.string()
.optional()
.describe('The directory where the sub-agent should operate'),
relevantFilesDirectories: z
.string()
.optional()
.describe('A list of files, which may include ** or * wildcard characters'),
});
const returnSchema = z.object({
instanceId: z.string().describe('The ID of the created agent instance'),
status: z.string().describe('The current status of the agent'),
});
// Implementation will start the agent asynchronously and return immediately agentMessage.tsimport { z } from 'zod';
import { zodToJsonSchema } from 'zod-to-json-schema';
import { Tool } from '../../core/types.js';
import { agentStates } from './agentState.js';
const parameterSchema = z.object({
instanceId: z.string().describe('The ID returned by agentStart'),
instruction: z
.string()
.optional()
.describe('Optional instruction or guidance to send to the agent'),
action: z
.enum(['get_status', 'pause', 'resume', 'terminate'])
.optional()
.describe('Action to perform on the agent'),
description: z
.string()
.describe('The reason for this agent interaction (max 80 chars)'),
});
const returnSchema = z.object({
status: z.string().describe('The current status of the agent'),
result: z.string().describe('The current result or output from the agent'),
error: z.string().optional().describe('Error message if any'),
});
// Implementation will handle bidirectional communication with the agent 3. Execution Flow
4. Testing Strategy
5. Documentation Updates
6. Timeline Estimate
Total: 1-2 weeks depending on complexity and integration challenges |
/mycoder, can you implement this as a PR? |
I've implemented the The PR is available here: #205 Key features implemented:
The implementation allows for:
|
I've implemented the The PR is available here: #205 Key features implemented:
The implementation allows for:
Let me know if you'd like any changes or have any questions about the implementation! |
# [mycoder-agent-v1.1.0](mycoder-agent-v1.0.0...mycoder-agent-v1.1.0) (2025-03-12) ### Bug Fixes * convert absolute paths to relative paths in textEditor log output ([a5ea845](a5ea845)) * implement resource cleanup to prevent CLI hanging issue ([d33e729](d33e729)), closes [#141](#141) * llm choice working well for openai, anthropic and ollama ([68d34ab](68d34ab)) * **openai:** add OpenAI dependency to agent package and enable provider in config ([30b0807](30b0807)) * replace @semantic-release/npm with @anolilab/semantic-release-pnpm to properly resolve workspace references ([bacb51f](bacb51f)) * up subagent iterations to 200 from 50 ([b405f1e](b405f1e)) ### Features * add agent tracking to background tools ([4a3bcc7](4a3bcc7)) * add Ollama configuration options ([d5c3a96](d5c3a96)) * **agent:** implement agentStart and agentMessage tools ([62f8df3](62f8df3)), closes [#111](#111) [#111](#111) * allow textEditor to overwrite existing files with create command ([d1cde65](d1cde65)), closes [#192](#192) * implement background tool tracking (issue [#112](#112)) ([b5bb489](b5bb489)) * implement Ollama provider for LLM abstraction ([597211b](597211b)) * **llm:** add OpenAI support to LLM abstraction ([7bda811](7bda811)) * **refactor:** agent ([a2f59c2](a2f59c2))
🎉 This issue has been resolved in version mycoder-agent-v1.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Transform subAgent tool into agentStart and agentMessage tools
Problem Statement
Currently, the subAgent tool creates a sub-agent that runs autonomously until completion. This can lead to sub-agents getting off task and wasting time, as there's no way for the parent agent to monitor or intervene in the sub-agent's execution.
Proposed Solution
Transform the subAgent tool into two separate tools similar to how shellStart and shellMessage work:
agentStart: Starts a sub-agent and immediately returns an instance ID
agentMessage: Bidirectional communication with a running sub-agent
Benefits
Requirements
agentStart Tool
agentMessage Tool
Implementation Notes
Acceptance Criteria
The text was updated successfully, but these errors were encountered: