Patch-Script Writer & Reviewer Agents
Architected a two-agent AutoGen writer/reviewer loop that generates Windows install and uninstall scripts in house style and security-reviews them before hand-off, with bounded termination limiting each turn to one write-review cycle.
- Role
- Lead engineer · agents, orchestration & backend
- Year
- 2025
- Type
- Multi-agent
- Stack
- AutoGen AgentChat · Azure OpenAI · Python · FastAPI · WebSockets · React · TypeScript · PyJWT · Prism · Material UI
- cooperating agents
- 2
- few-shot script pairs
- 9
- shell dialects reviewed
- 4
The problem
Packaging software for a large managed desktop estate needs many small, convention-heavy scripts: silent MSI installs with transforms, prior-version removal, registry markers and product-code uninstallers. Writing them by hand was slow and error-prone, and the end-user-device team needed drafts that followed their conventions and were reviewed before an engineer used them.
Architecture
- 01
Request
The engineer specifies software, version and installer details in a JWT-scoped chat session over WebSockets.
- 02
Write
A coder agent, few-shot primed with nine real script pairs, emits matched install and uninstall batch scripts.
- 03
Review
A reviewer agent audits security, dependency risk, error handling, logging and production readiness.
- 04
Terminate
Source-match termination on the reviewer OR an APPROVED text mention returns control to the human after one cycle.
- 05
Render
React splits Markdown into prose and code segments, with Prism highlighting and per-block copy buttons.
- 06
Persist
Team state saved per session for conversational refinement, with scheduled cleanup of expired sessions.
Engineering highlights
01
Bounded multi-agent loop
Combined SourceMatchTermination and TextMentionTermination guarantee exactly one write-then-review cycle per user turn, preventing unbounded agent-to-agent loops and keeping token cost predictable.
02
Re-architected orchestration
Replaced a three-member round-robin with a UserProxyAgent and no termination, which forced the WebSocket handler to inject input into a running team, with explicit termination conditions on a shared per-agent scaffold.
03
Prompt as style guide
Encoded house conventions through nine real script pairs rather than rules: relative installer paths, centralised logs, ERRORLEVEL exit labels, suppressed reboots, MSI transforms, AppX provisioning and rollback uninstalls.
04
Cross-dialect reviewer
A separate validation prompt reviews scripts across PowerShell, CMD, Bash/Dash and Unix shell, flagging security flaws, dependency risks, missing logging and weak error handling before testing.
05
Stateful iteration
Team state persists per session between turns, so engineers refine drafts conversationally, for example killing a running process first, while both agents keep their earlier context.