Agent Zero AI framework
agent no. from backend
3clyp50ced8f87e8ea4
diff --git a/python/helpers/log.py b/python/helpers/log.pyindex d2cdcc40e..112f0bf74 100644--- a/python/helpers/log.py+++ b/python/helpers/log.py@@ -136,10 +136,16 @@ class LogItem:duration_ms: Optional[int] = None # Duration until next step (set by Log.log)tokens_in: int = 0 # Input tokens consumedtokens_out: int = 0 # Output tokens generated+ agent_number: int = 0 # Agent number (0 = main agent, 1+ = subordinate agents)def __post_init__(self):self.guid = self.log.guidself.timestamp = time.time() # Record creation time+ # Capture agent number from context if available+ if self.log.context and self.log.context.streaming_agent:+ self.agent_number = self.log.context.streaming_agent.number+ else:+ self.agent_number = 0 # Default to main agentdef update(self,@@ -202,6 +208,7 @@ class LogItem:"duration_ms": self.duration_ms, # Duration until next step"tokens_in": self.tokens_in, # Input tokens"tokens_out": self.tokens_out, # Output tokens+ "agent_number": self.agent_number, # Agent number for identifying main/subordinate agents}diff --git a/webui/index.js b/webui/index.jsindex 3cb695496..8ee354f62 100644--- a/webui/index.js+++ b/webui/index.js@@ -185,8 +185,8 @@ async function updateUserTime() {updateUserTime();setInterval(updateUserTime, 1000);-function setMessage(id, type, heading, content, temp, kvps = null, timestamp = null, durationMs = null, tokensIn = 0, tokensOut = 0) {- const result = msgs.setMessage(id, type, heading, content, temp, kvps, timestamp, durationMs, tokensIn, tokensOut);+function setMessage(id, type, heading, content, temp, kvps = null, timestamp = null, durationMs = null, tokensIn = 0, tokensOut = 0, agentNumber = 0) {+ const result = msgs.setMessage(id, type, heading, content, temp, kvps, timestamp, durationMs, tokensIn, tokensOut, agentNumber);const chatHistoryEl = document.getElementById("chat-history");if (preferencesStore.autoScroll && chatHistoryEl) {chatHistoryEl.scrollTop = chatHistoryEl.scrollHeight;@@ -314,7 +314,8 @@ export async function poll() {log.timestamp,log.duration_ms,log.tokens_in,- log.tokens_out+ log.tokens_out,+ log.agent_number || 0 // Agent number for identifying main/subordinate agents);}afterMessagesUpdate(response.logs);diff --git a/webui/js/messages.js b/webui/js/messages.jsindex 04879830a..07a1a5556 100644--- a/webui/js/messages.js+++ b/webui/js/messages.js@@ -17,19 +17,7 @@ const PROCESS_TYPES = ['agent', 'tool', 'code_exe', 'browser', 'info', 'hint', '// Main types that should always be visible (not collapsed)const MAIN_TYPES = ['user', 'response', 'error', 'rate_limit'];-/**- * Check if a response is from the main agent (A0)- * Subordinate agents (A1, A2, ...) responses should be treated as process steps- */-function isMainAgentResponse(heading) {- if (!heading) return true; // Default to main agent- // Check for subordinate agent patterns like "A1:", "A2:", etc.- const match = heading.match(/\bA(\d+):/);- if (!match) return true; // No agent marker = main agent- return match[1] === "0"; // Only A0 is the main agent-}--export function setMessage(id, type, heading, content, temp, kvps = null, timestamp = null, durationMs = null, tokensIn = 0, tokensOut = 0) {+export function setMessage(id, type, heading, content, temp, kvps = null, timestamp = null, durationMs = null, tokensIn = 0, tokensOut = 0, agentNumber = 0) {// Check if this is a process type messageconst isProcessType = PROCESS_TYPES.includes(type);const isMainType = MAIN_TYPES.includes(type);@@ -64,7 +52,8 @@ export function setMessage(id, type, heading, content, temp, kvps = null, timest}// For subordinate agent responses (A1, A2, ...), treat as a process step instead of main response- if (type === "response" && !isMainAgentResponse(heading)) {+ // agentNumber: 0 = main agent, 1+ = subordinate agents+ if (type === "response" && agentNumber !== 0) {if (processStepElement) {updateProcessStep(processStepElement, id, "agent", heading, content, kvps, durationMs, tokensIn, tokensOut);return processStepElement;@@ -1118,8 +1107,11 @@ function createProcessGroup(id) {group.classList.add("process-group");group.setAttribute("data-group-id", groupId);- // Default to collapsed state - don't add 'expanded' class- // (Users can expand manually by clicking)+ // Check initial expansion state from store (respects user preference)+ const initiallyExpanded = processGroupStore.isGroupExpanded(groupId);+ if (initiallyExpanded) {+ group.classList.add('expanded');+ }// Create headerconst header = document.createElement("div");@@ -1724,7 +1716,7 @@ function markProcessGroupComplete(group, responseTitle) {const statusEl = group.querySelector(".group-status");if (statusEl) {statusEl.innerHTML = '<span class="badge-icon material-symbols-outlined">check_circle</span>END';- statusEl.className = "status-badge status-response group-status"; // No status-active+ statusEl.className = "status-badge status-end group-status"; // No status-active}// Remove status-active from all step badges (stop spinners)