How SwarmForge Extracts Status Information from Agent Output: Pane Parsing Logic Explained
SwarmForge extracts status information from agent output by scanning pane files backwards for lines containing the keywords "I'm" or "I'll", filtering out tool traces and handoff noise, and displaying the last valid status sentence on the dashboard card.
The unclebob/swarm-forge repository implements a specialized parsing pipeline that converts verbose agent logs into concise status updates. Understanding how SwarmForge extracts status information from agent output requires examining the regex-based detection, backwards line scanning, and noise-filtering algorithms implemented in the core source files.
The Status Extraction Pipeline
SwarmForge processes agent activity through a three-stage pipeline that transforms raw pane output into dashboard-ready status strings.
Reading Agent Pane Files
The extraction begins by reading the agent's live pane output from the project's handoff directory. The system locates pane files within the .swarmforge/handoffs/ structure as defined in the handoff protocol.
- The
pack_web.bbscript inswarmforge/scripts/pack_web.bborchestrates the file reading process - Each project maintains isolated status streams to prevent cross-contamination
- The extractor operates on the most recent pane file content, not historical logs
Detecting Status Keywords
The core extraction logic searches for specific linguistic markers that indicate agent self-reporting. The implementation scans lines in reverse order (newest first) and identifies the first line matching the status pattern.
- Regex pattern: Lines containing
I['']?morI['']?ll(handling both "I'm" and "I'll" variations) - Backwards scanning: The algorithm checks from the end of the file backwards to find the most recent status update
- Sentence extraction: The entire line containing the match becomes the candidate status string
Filtering Noise and Tool Traces
Before accepting a candidate line, the extractor applies aggressive filtering to remove machine-generated chatter and non-status content.
The following patterns are explicitly discarded:
- Test output lines such as
Ran 7 tests - Navigation hints like
view transcript - Handoff protocol banners including
ready_for_next - Any line lacking the explicit status keywords
This filtering ensures that only human-readable activity descriptions surface on the dashboard cards.
Implementation in Source Code
The extraction logic resides in the Clojure source tree, with complementary shell scripting for execution context.
Core Extraction Function
In src/swarmforge/pack_web.clj, the extract-status function implements the backwards-scanning regex matcher:
(defn extract-status
"Extracts the last status line from pane content.
Returns the most recent line containing 'I'm' or 'I'll',
ignoring tool traces and handoff noise."
[pane-content]
(->> (str/split-lines pane-content)
(reverse)
(filter #(re-find #"(?i)\b(I['']?m|I['']?ll)\b" %))
(remove #(re-find #"Ran \d+ tests|view transcript|ready_for_next" %))
(first)))
The function signature accepts raw pane content as a string and returns the cleaned status line or nil if no valid status exists.
Bash Wrapper Execution
The swarmforge/scripts/pack_web.bb file provides the execution environment that invokes the Clojure extraction logic:
#!/usr/bin/env bb
# pack_web.bb - Orchestrates status extraction and dashboard rendering
# Invoke status extraction with test flags for validation
pack-web-env "$REPO_ROOT" {} --test-status-pane "$REPO_ROOT"
This Babashka script handles environment setup before delegating to the Clojure namespace for actual parsing.
Validation Through Testing
The test/swarmforge/pack_web_test.clj file contains comprehensive test suites that verify extraction behavior under various edge cases.
Persistence Testing
The --test-status-persist flag verifies that extracted status persists across pane updates until explicitly replaced by a new status sentence:
(deftest test-status-persistence
(testing "Status persists until replaced by new status line"
(is (= "I'm idle, so I'm running ready_for_next.sh"
(extract-status updated-pane-content)))))
Project Isolation Verification
The forge-card-status-is-per-project test ensures that status extraction respects project boundaries:
(deftest forge-card-status-is-per-project
(testing "Status from project A does not leak into project B"
(let [project-a-status (extract-status project-a-pane)
project-b-status (extract-status project-b-pane)]
(is (not= project-a-status project-b-status)))))
Integration Testing
Test environments utilize the --test-status-pane flag to simulate dashboard rendering scenarios:
# Execute status extraction in test context
clojure -M:test -m swarmforge.pack-web-test --test-status-pane
Summary
- Backwards scanning: SwarmForge reads pane files from end to start to find the most recent status update
- Keyword detection: The system exclusively recognizes lines containing "I'm" or "I'll" as valid status indicators
- Noise filtering: Tool traces, test summaries, and handoff banners are programmatically excluded from extraction
- Per-project isolation: Status extraction operates within project boundaries, preventing cross-contamination between different agent workspaces
- Persistence model: Once extracted, status remains displayed until a newer status sentence appears in the pane output
Frequently Asked Questions
What specific keywords does SwarmForge look for when extracting status?
SwarmForge searches for lines containing the case-insensitive patterns "I'm" or "I'll" (including variations like "Im" or "Ill" without apostrophes). According to the source code in src/swarmforge/pack_web.clj, the regex (?i)\b(I['']?m|I['']?ll)\b matches these status indicators while ignoring surrounding context.
How does SwarmForge handle multiple status lines in a single pane?
The extractor implements backwards scanning logic, checking lines from the end of the file towards the beginning. The first line (chronologically most recent) that matches the status keywords and passes the noise filter becomes the extracted status. Earlier status lines in the same pane are ignored, ensuring only the latest agent statement appears on the dashboard.
Why does SwarmForge filter out lines containing "Ran 7 tests" or "view transcript"?
These strings represent machine-generated output rather than agent self-reporting. The test suite in test/swarmforge/pack_web_test.clj explicitly validates that lines matching patterns like Ran \d+ tests and view transcript are excluded from status extraction. This filtering prevents test summaries and navigation UI elements from polluting the activity display.
How does the system maintain status isolation between different projects?
The forge-card-status-is-per-project test verifies that each project maintains independent status tracking. The extraction logic in pack_web.clj operates on project-specific pane files located in distinct .swarmforge/handoffs/ subdirectories, ensuring that agent output from one repository never influences the status cards displayed for another project.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →