Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat: add detailed tool activity display for running agents

Adam Eivy0d26d668f270
diff --git a/.changelog/v0.11.x.md b/.changelog/v0.11.x.md
index ef7237e062..763cd41045 100644
--- a/.changelog/v0.11.x.md
+++ b/.changelog/v0.11.x.md
@@ -177,3 +177,11 @@ This release focuses on security improvements, bug fixes for the AI runner syste
- **Tool Use Visibility**: Shows tool invocations (e.g., "🔧 Using Edit...") in the live output so users can see what the agent is doing
- **Both Spawn Modes**: Works in both direct spawn mode and via the standalone CoS Runner (PM2 process)
- **Clean Output Files**: The final output file contains the clean result text, while the raw JSON stream is preserved for error analysis
+
+### Detailed Agent Tool Activity Display
+- **Tool Input Details**: Agent output now shows what each tool is operating on — file paths for Read/Edit/Write, search patterns for Grep/Glob, commands for Bash, queries for WebSearch, and descriptions for Task spawns
+- **Input JSON Delta Parsing**: Stream parser now accumulates `input_json_delta` events and emits detailed summaries when `content_block_stop` fires, providing context like `🔧 Using Grep... → "pattern" in …/services/api.js`
+- **Rich Live Activity Feed**: Running agent cards show the last few tool actions with details instead of just the tool name, giving immediate insight into what the agent is doing
+- **Color-Coded Expanded View**: Expanded agent output now color-codes tool invocations (accent blue), input details (gray), and tool results (dim gray) for easy scanning
+- **Scrollable Output**: Expanded output view is now height-limited and scrollable to prevent page layout issues with verbose agents
+- **Tool Counter**: Shows total tool invocation count when agents use more than 3 tools
diff --git a/client/src/components/cos/tabs/AgentCard.jsx b/client/src/components/cos/tabs/AgentCard.jsx
index 514897fc59..058cb22137 100644
--- a/client/src/components/cos/tabs/AgentCard.jsx
+++ b/client/src/components/cos/tabs/AgentCard.jsx
@@ -150,6 +150,25 @@ export default function AgentCard({ agent, onKill, onDelete, onResume, completed
: (liveOutput || agent.output || []);
const lastOutput = output.length > 0 ? output[output.length - 1]?.line : null;
+ // Extract recent tool activity (last few tool lines) for live display
+ const recentActivity = useMemo(() => {
+ if (completed || output.length === 0) return [];
+ const recent = [];
+ // Walk backwards to find the last 3 tool actions (🔧 lines with their → details)
+ for (let i = output.length - 1; i >= 0 && recent.length < 6; i--) {
+ const line = output[i]?.line || '';
+ if (line.startsWith('🔧') || line.startsWith(' →')) {
+ recent.unshift(output[i]);
+ }
+ }
+ return recent;
+ }, [completed, output]);
+
+ // Count total tool invocations
+ const toolCount = useMemo(() => {
+ return output.filter(o => o?.line?.startsWith('🔧')).length;
+ }, [output]);
+
return (
<div className={`bg-port-card border rounded-lg overflow-hidden ${
completed
@@ -281,10 +300,27 @@ export default function AgentCard({ agent, onKill, onDelete, onResume, completed
</div>
<p className="text-white text-sm mb-2">{agent.metadata?.taskDescription || agent.taskId}</p>
- {/* Status / Last output line */}
- {!completed && lastOutput && (
+ {/* Live activity feed for running agents */}
+ {!completed && recentActivity.length > 0 && (
+ <div className="text-xs font-mono bg-port-bg/50 px-2 py-1.5 rounded space-y-0.5">
+ {recentActivity.map((o, i) => {
+ const line = o.line || '';
+ if (line.startsWith('🔧')) {
+ return <div key={i} className="text-gray-400 truncate">{line}</div>;
+ }
+ if (line.startsWith(' →')) {
+ return <div key={i} className="text-gray-500 truncate pl-4">{line.substring(4)}</div>;
+ }
+ return <div key={i} className="text-gray-500 truncate">{line.substring(0, 100)}</div>;
+ })}
+ {toolCount > 3 && (
+ <div className="text-gray-600 text-[10px]">{toolCount} tools used</div>
+ )}
+ </div>
+ )}
+ {!completed && recentActivity.length === 0 && lastOutput && (
<div className="text-xs text-gray-500 font-mono truncate bg-port-bg/50 px-2 py-1 rounded">
- {lastOutput.substring(0, 100)}...
+ {lastOutput.substring(0, 100)}
</div>
)}
@@ -348,19 +384,27 @@ export default function AgentCard({ agent, onKill, onDelete, onResume, completed
{/* Expanded output view */}
{expanded && (
- <div className="border-t border-port-border bg-port-bg/50 p-3">
+ <div className="border-t border-port-border bg-port-bg/50 p-3 max-h-96 overflow-y-auto">
{loadingOutput ? (
<div className="flex items-center gap-2 text-gray-500 text-sm">
<Loader2 size={14} aria-hidden="true" className="animate-spin" />
Loading full output...
</div>
) : output.length > 0 ? (
- <pre className="text-xs font-mono text-gray-400 whitespace-pre-wrap">
- {output.map((o, i) => (
- <div key={i} className="py-0.5">
- {o.line}
- </div>
- ))}
+ <pre className="text-xs font-mono whitespace-pre-wrap">
+ {output.map((o, i) => {
+ const line = o.line || '';
+ if (line.startsWith('🔧')) {
+ return <div key={i} className="py-0.5 text-port-accent">{line}</div>;
+ }
+ if (line.startsWith(' →')) {
+ return <div key={i} className="py-0.5 text-gray-500 pl-4">{line.substring(4)}</div>;
+ }
+ if (line.startsWith(' ↳')) {
+ return <div key={i} className="py-0.5 text-gray-600 pl-4">{line.substring(4)}</div>;
+ }
+ return <div key={i} className="py-0.5 text-gray-400">{line}</div>;
+ })}
</pre>
) : (
<div className="text-gray-500 text-sm">No output captured</div>
diff --git a/server/cos-runner/index.js b/server/cos-runner/index.js
index fd7345078e..7d028b1215 100644
--- a/server/cos-runner/index.js
+++ b/server/cos-runner/index.js
@@ -54,6 +54,46 @@ function isAllowedCommand(command) {
return ALLOWED_COMMANDS.has(baseName);
}
+/**
+ * Summarize tool input into a concise description for display.
+ */
+function summarizeToolInput(toolName, input) {
+ if (!input || typeof input !== 'object') return '';
+ const shorten = (p) => {
+ if (!p || typeof p !== 'string') return '';
+ const parts = p.split('/').filter(Boolean);
+ return parts.length > 2 ? `…/${parts.slice(-2).join('/')}` : p;
+ };
+ switch (toolName) {
+ case 'Read':
+ return shorten(input.file_path);
+ case 'Edit':
+ return shorten(input.file_path);
+ case 'Write':
+ return shorten(input.file_path);
+ case 'Glob':
+ return input.pattern || '';
+ case 'Grep':
+ return `"${(input.pattern || '').substring(0, 60)}"${input.path ? ` in ${shorten(input.path)}` : ''}`;
+ case 'Bash': {
+ const cmd = input.command || input.description || '';
+ return cmd.substring(0, 80);
+ }
+ case 'Task':
+ return input.description || '';
+ case 'WebFetch':
+ return shorten(input.url || '');
+ case 'WebSearch':
+ return `"${(input.query || '').substring(0, 60)}"`;
+ case 'TodoWrite':
+ return input.todos?.length ? `${input.todos.length} items` : '';
+ case 'NotebookEdit':
+ return shorten(input.notebook_path);
+ default:
+ return '';
+ }
+}
+
/**
* Create a Claude stream-json parser that extracts human-readable text from JSON stream events.
* Returns a stateful parser with a `processChunk(data)` method that returns extracted text lines.
@@ -62,6 +102,7 @@ function createStreamJsonParser() {
let lineBuffer = '';
let finalResult = '';
let textBuffer = '';
+ const activeTools = new Map();
const processChunk = (rawData) => {
const lines = [];
@@ -89,10 +130,34 @@ function createStreamJsonParser() {
lines.push(tl);
}
}
+ // Accumulate tool input JSON deltas
+ if (event?.type === 'content_block_delta' && event.delta?.type === 'input_json_delta') {
+ const idx = event.index;
+ const tool = activeTools.get(idx);
+ if (tool) {
+ tool.inputJson += event.delta.partial_json || '';
+ }
+ }
if (event?.type === 'content_block_start' && event.content_block?.type === 'tool_use') {
const toolName = event.content_block.name || 'unknown';
+ const idx = event.index;
+ activeTools.set(idx, { name: toolName, inputJson: '' });
lines.push(`🔧 Using ${toolName}...`);
}
+ // Emit detailed summary when tool input is complete
+ if (event?.type === 'content_block_stop') {
+ const idx = event.index;
+ const tool = activeTools.get(idx);
+ if (tool && tool.inputJson) {
+ let input;
+ input = JSON.parse(tool.inputJson);
+ const detail = summarizeToolInput(tool.name, input);
+ if (detail) {
+ lines.push(` → ${detail}`);
+ }
+ activeTools.delete(idx);
+ }
+ }
}
if (parsed.type === 'assistant') {
diff --git a/server/services/subAgentSpawner.js b/server/services/subAgentSpawner.js
index 7e1e7fca6c..63cd061320 100644
--- a/server/services/subAgentSpawner.js
+++ b/server/services/subAgentSpawner.js
@@ -1637,18 +1637,64 @@ async function spawnDirectly(agentId, task, prompt, workspacePath, model, provid
return agentId;
}
+/**
+ * Summarize tool input into a concise description for display.
+ * Extracts the most relevant parameter from each tool type.
+ */
+function summarizeToolInput(toolName, input) {
+ if (!input || typeof input !== 'object') return '';
+ const shorten = (p) => {
+ if (!p || typeof p !== 'string') return '';
+ // Strip long absolute paths to just filename or last 2 segments
+ const parts = p.split('/').filter(Boolean);
+ return parts.length > 2 ? `…/${parts.slice(-2).join('/')}` : p;
+ };
+ switch (toolName) {
+ case 'Read':
+ return shorten(input.file_path);
+ case 'Edit':
+ return shorten(input.file_path);
+ case 'Write':
+ return shorten(input.file_path);
+ case 'Glob':
+ return input.pattern || '';
+ case 'Grep':
+ return `"${(input.pattern || '').substring(0, 60)}"${input.path ? ` in ${shorten(input.path)}` : ''}`;
+ case 'Bash': {
+ const cmd = input.command || input.description || '';
+ return cmd.substring(0, 80);
+ }
+ case 'Task':
+ return input.description || '';
+ case 'WebFetch':
+ return shorten(input.url || '');
+ case 'WebSearch':
+ return `"${(input.query || '').substring(0, 60)}"`;
+ case 'TodoWrite':
+ return input.todos?.length ? `${input.todos.length} items` : '';
+ case 'NotebookEdit':
+ return shorten(input.notebook_path);
+ default:
+ return '';
+ }
+}
+
/**
* Create a Claude stream-json parser that extracts human-readable text from JSON stream events.
* Returns a stateful parser with a `processChunk(data)` method that returns extracted text lines.
* The parser handles:
* - content_block_delta: incremental text tokens as they stream
- * - tool_use events: shows tool calls for visibility (e.g. "🔧 Using Edit on file.js")
+ * - tool_use events: shows tool calls with input details (e.g. "🔧 Read …/services/api.js")
+ * - input_json_delta: accumulates tool input JSON for detailed summaries
+ * - content_block_stop: emits detailed tool summary when input is complete
* - result: final result text (used for output file)
*/
function createStreamJsonParser() {
let lineBuffer = '';
let finalResult = '';
let textBuffer = '';
+ // Track active tool blocks by index for input accumulation
+ const activeTools = new Map(); // index -> { name, inputJson }
const processChunk = (rawData) => {
const lines = [];
@@ -1682,11 +1728,36 @@ function createStreamJsonParser() {
lines.push(tl);
}
}
- // Show tool use starts for visibility
+ // Accumulate tool input JSON deltas
+ if (event?.type === 'content_block_delta' && event.delta?.type === 'input_json_delta') {
+ const idx = event.index;
+ const tool = activeTools.get(idx);
+ if (tool) {
+ tool.inputJson += event.delta.partial_json || '';
+ }
+ }
+ // Track tool use start - record name and begin accumulating input
if (event?.type === 'content_block_start' && event.content_block?.type === 'tool_use') {
const toolName = event.content_block.name || 'unknown';
+ const idx = event.index;
+ activeTools.set(idx, { name: toolName, inputJson: '' });
lines.push(`🔧 Using ${toolName}...`);
}
+ // When tool input is complete, emit a detailed summary line
+ if (event?.type === 'content_block_stop') {
+ const idx = event.index;
+ const tool = activeTools.get(idx);
+ if (tool && tool.inputJson) {
+ let input;
+ // Parse accumulated JSON - may be incomplete for very large inputs
+ input = JSON.parse(tool.inputJson);
+ const detail = summarizeToolInput(tool.name, input);
+ if (detail) {
+ lines.push(` → ${detail}`);
+ }
+ activeTools.delete(idx);
+ }
+ }
}
// Extract tool results from assistant messages