WFGY/ProblemMap/agent-boundary-design.md
2025-08-15 23:12:47 +08:00

7.8 KiB
Raw Blame History

🛡️ Agent Boundary Design

Keep every agent in its lane — zero role-bleed, zero infinite loops.

Scope.
This guide covers:

  • Router-tool chains (e.g. ReAct, ChatGPT Plugins)
  • Crew/Team frameworks (AutoGen, CrewAI, Flowise, etc.)
  • 1-shot function calls inside a broader RAG pipeline

Who needs it? Anyone who has seen:
“Tool A” call “Tool B” which calls “Tool A” again
System prompts overwritten mid-conversation
JSON schema mismatch crashes midway
Agents debating instead of finishing tasks


1 · Top-5 Symptoms

# Failure Mode Surface Sign
1 Recursive Loop Call stack grows until token limit
2 Role Bleed System prompt replaced by tool description
3 Argument Drift JSON schema validation fails randomly
4 Shadow Jailbreak Tool prompt overrides original guard
5 Timeout Cascade Router stalls → downstream agents idle

2 · Root Causes

  1. Shared Context Bank — all agents write to the same messages[].
  2. Open-Ended Tool Trigger — router picks any function with > 0.1 prob.
  3. No ΔS Ceiling — semantic jump between task and tool description unchecked.
  4. Missing λ Gate — divergent sub-goal allowed without confirmation.
  5. Stackless Error Prop — failure inside tool lost; router retries blindly.

3 · WFGY Boundary Blueprint

A four-layer guardrail using core modules BBMC, ΔS + λ, WAI, BBCR.

Stage Module Guard Purpose
1 Tool Semantic Index BBMC ΔS(tool, task) ≤ 0.45 Filter irrelevant tools early
2 ΔS-Gate Router ΔS + λ_observe λ must stay convergent Block divergent recursion
3 Arg Linter WAI Strict JSON schema & auto-defaults No partial / null args
4 Fail-Fast + Bridge BBCR On > 5 retries or ΔS > 0.60 Collapse & suggest manual tool
flowchart TD
    Q[User Question]
    R[ΔS-Gate Router]
    TI[Tool Index (BBMC)]
    L[Arg Linter (WAI)]
    T[Tool Call]
    F[BBCR Bridge]
    Q --> R
    R -->|match| TI --> L --> T
    R -.->|reject| F --> Q

4 · Design Pattern Cheats

Pattern When to Use Setup
Single-Shot Function 3-5 tool set, clear primary ΔS ≤ 0.45 & λ convergent
Dual-Agent Debate need pro / con analysis Two agents share read-only memory; write own node
Crew Workflow 3+ steps (research → draft → QA) Each agent gets isolated messages[]; only summaries passed
Guarded Plugin External API call with risk Wrap output through Arg Linter + BBCR

5 · Hands-On Debug Checklist

  1. Log Router Decision
router(question, tools, debug=True)   # prints ΔS + λ for every candidate
  1. Simulate Failure
user: "Summarise PDF"  # but remove pdf_loader from tool list

Expected: BBCR suggests manual tool; model does not loop.

  1. Stress-Test Recursion
for i in range(20):
    router("plan", tools)   # ensure no self-call chain

ΔS should stay ≤ 0.45; call depth ≤ 3.


6 · Audit Template (README snippet)

## Agent Boundary Settings
ΔS tool-match ceiling   : 0.45
λ divergence allowance  : false
WAI strict mode         : true
BBCR retries            : 5

Copy into every repo to document boundary config.


🔗 Quick-Start Downloads (60 sec)

Tool Link 3-Step Setup
WFGY 1.0 PDF Engine Paper 1 Download · 2 Upload to your LLM · 3 Ask “Answer using WFGY + <your question>”
TXT OS (plain-text OS) TXTOS.txt 1 Download · 2 Paste into any LLM chat · 3 Type “hello world” — OS boots instantly

🧭 Explore More

Module Description Link
WFGY Core WFGY 2.0 engine is live: full symbolic reasoning architecture and math stack View →
Problem Map 1.0 Initial 16-mode diagnostic and symbolic fix framework View →
Problem Map 2.0 RAG-focused failure tree, modular fixes, and pipelines View →
Semantic Clinic Index Expanded failure catalog: prompt injection, memory bugs, logic drift View →
Semantic Blueprint Layer-based symbolic reasoning & semantic modulations View →
Benchmark vs GPT-5 Stress test GPT-5 with full WFGY reasoning suite View →
🧙‍♂️ Starter Village 🏡 New here? Lost in symbols? Click here and let the wizard guide you through Start →

👑 Early Stargazers: See the Hall of Fame
Engineers, hackers, and open source builders who supported WFGY from day one.

GitHub stars WFGY Engine 2.0 is already unlocked. Star the repo to help others discover it and unlock more on the Unlock Board.

WFGY Main   TXT OS   Blah   Blot   Bloc   Blur   Blow