Skip to content

Commit 86a4f30

Browse files
authored
Merge pull request #325 from drivecore/fix-324-agent-log-capture
Capture log messages from agent and its immediate tools in AgentTracker output
2 parents 2867772 + 226fa98 commit 86a4f30

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+697
-503
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export default {
9898

9999
// Base URL configuration (for providers that need it)
100100
baseUrl: 'http://localhost:11434', // Example for Ollama
101-
101+
102102
// MCP configuration
103103
mcp: {
104104
servers: [
@@ -182,4 +182,4 @@ Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute t
182182

183183
## License
184184

185-
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
185+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

docs/github-comment-commands.md

Lines changed: 0 additions & 83 deletions
This file was deleted.

docs/release-process.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/tools/agent-tools.md

Lines changed: 0 additions & 130 deletions
This file was deleted.

packages/agent/README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,29 +69,36 @@ MyCoder Agent supports the Model Context Protocol:
6969
## Available Tools
7070

7171
### File & Text Manipulation
72+
7273
- **textEditor**: View, create, and edit files with persistent state
7374
- Commands: view, create, str_replace, insert, undo_edit
7475
- Line number support and partial file viewing
7576

7677
### System Interaction
78+
7779
- **shellStart**: Execute shell commands with sync/async modes
7880
- **shellMessage**: Interact with running shell processes
7981
- **shellExecute**: One-shot shell command execution
8082
- **listShells**: List all running shell processes
8183

8284
### Agent Management
85+
8386
- **agentStart**: Create sub-agents for parallel tasks
84-
- **agentMessage**: Send messages to sub-agents
87+
- **agentMessage**: Send messages to sub-agents and retrieve their output (including captured logs)
8588
- **agentDone**: Complete the current agent's execution
8689
- **listAgents**: List all running agents
8790

91+
The agent system automatically captures log, warn, and error messages from agents and their immediate tools, which are included in the output returned by agentMessage.
92+
8893
### Network & Web
94+
8995
- **fetch**: Make HTTP requests to APIs
9096
- **sessionStart**: Start browser automation sessions
9197
- **sessionMessage**: Control browser sessions (navigation, clicking, typing)
9298
- **listSessions**: List all browser sessions
9399

94100
### Utility Tools
101+
95102
- **sleep**: Pause execution for a specified duration
96103
- **userPrompt**: Request input from the user
97104

@@ -145,10 +152,10 @@ const tools = [textEditorTool, shellStartTool];
145152

146153
// Run the agent
147154
const result = await toolAgent(
148-
"Write a simple Node.js HTTP server and save it to server.js",
155+
'Write a simple Node.js HTTP server and save it to server.js',
149156
tools,
150157
{
151-
getSystemPrompt: () => "You are a helpful coding assistant...",
158+
getSystemPrompt: () => 'You are a helpful coding assistant...',
152159
maxIterations: 10,
153160
},
154161
{
@@ -157,7 +164,7 @@ const result = await toolAgent(
157164
model: 'claude-3-opus-20240229',
158165
apiKey: process.env.ANTHROPIC_API_KEY,
159166
workingDirectory: process.cwd(),
160-
}
167+
},
161168
);
162169

163170
console.log('Agent result:', result);
@@ -169,4 +176,4 @@ We welcome contributions! Please see our [CONTRIBUTING.md](../CONTRIBUTING.md) f
169176

170177
## License
171178

172-
MIT
179+
MIT

packages/agent/src/core/executeToolCall.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ export const executeToolCall = async (
7373
if (tool.logParameters) {
7474
tool.logParameters(validatedJson, toolContext);
7575
} else {
76-
logger.info('Parameters:');
76+
logger.log('Parameters:');
7777
Object.entries(validatedJson).forEach(([name, value]) => {
78-
logger.info(` - ${name}: ${JSON.stringify(value).substring(0, 60)}`);
78+
logger.log(` - ${name}: ${JSON.stringify(value).substring(0, 60)}`);
7979
});
8080
}
8181

@@ -103,12 +103,12 @@ export const executeToolCall = async (
103103
if (tool.logReturns) {
104104
tool.logReturns(output, toolContext);
105105
} else {
106-
logger.info('Results:');
106+
logger.log('Results:');
107107
if (typeof output === 'string') {
108-
logger.info(` - ${output}`);
108+
logger.log(` - ${output}`);
109109
} else if (typeof output === 'object') {
110110
Object.entries(output).forEach(([name, value]) => {
111-
logger.info(` - ${name}: ${JSON.stringify(value).substring(0, 60)}`);
111+
logger.log(` - ${name}: ${JSON.stringify(value).substring(0, 60)}`);
112112
});
113113
}
114114
}

packages/agent/src/core/toolAgent/toolAgentCore.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe('toolAgentCore empty response detection', () => {
77
const fileContent = `
88
if (!text.length && toolCalls.length === 0) {
99
// Only consider it empty if there's no text AND no tool calls
10-
logger.verbose('Received truly empty response from agent (no text and no tool calls), sending reminder');
10+
logger.debug('Received truly empty response from agent (no text and no tool calls), sending reminder');
1111
messages.push({
1212
role: 'user',
1313
content: [

0 commit comments

Comments
 (0)