12 KiB
Tool Selection and Timeouts: Prompt Assembly
A focused guide to pick the right tool step, set safe timeouts, and keep long chains stable.
Use this page to localize failures in tool choice, call ordering, and retry behavior, then jump to the exact fix.
Open these first
- Visual map and recovery: rag-architecture-and-recovery.md
- End to end retrieval knobs: retrieval-playbook.md
- Traceability schema and cite-then-explain: retrieval-traceability.md
- Payload schema for tools and snippets: data-contracts.md
- Reranking and order control: rerankers.md
- Prompt injection hardening: prompt-injection.md
- Multi agent stalls and role drift: Multi-Agent_Problems.md, multi-agent-chaos/role-drift.md
- Context and entropy failures: context-drift.md, entropy-collapse.md
- Ops knobs for retries and backpressure:
GlobalFixMap/OpsDeploy/retry_backoff.md,
GlobalFixMap/OpsDeploy/rate_limit_backpressure.md
Companion pages in this folder
- JSON protocol: json_mode_and_tool_calls.md
- Anti-injection recipes: anti_prompt_injection_recipes.md
- Memory fences and state keys: memory_fences_and_state_keys.md
Core acceptance
- ΔS(question, retrieved) ≤ 0.45
- Coverage of target section ≥ 0.70
- λ remains convergent across three paraphrases and two seeds
- Tool error rate ≤ 1 percent on a 50 run sample
- p95 tool step latency within your SLO, usually 3–8 seconds per call for public APIs
Fix in 60 seconds
-
Measure ΔS and λ
Compute ΔS(question, retrieved) and ΔS(retrieved, expected anchor). If ΔS ≥ 0.60 and λ flips, the issue is schema or ordering. -
Clamp the plan
Prefer read-only checks before side effects. Gate tools behind JSON arguments that echo schemas from data-contracts.md. -
Set timeouts and retries
- Per-tool timeout = p95 × 1.5.
- Retries at most 2 with jittered backoff, never for unsafe side effects.
- Rate limit backpressure guard active on the whole chain.
Open: retry_backoff.md, rate_limit_backpressure.md.
Common failure signatures → structural fix
-
Wrong tool chosen for the question
Symptom: high ΔS, tool arguments look unrelated.
Fix: require tool-selection justification field and SCU when blocked.
Open: retrieval-traceability.md, patterns/pattern_symbolic_constraint_unlock.md. -
Query parsing split creates unstable hybrid results
Symptom: hybrid underperforms single retriever, top-k order changes across runs.
Fix: lock two-stage query, then rerank deterministically.
Open: patterns/pattern_query_parsing_split.md, rerankers.md. -
Timeout storms and looped retries
Symptom: repeated timeouts escalate load and cost.
Fix: per-tool circuit breaker plus global backpressure. No retry on non-idempotent tools.
Open: retry_backoff.md, rate_limit_backpressure.md. -
Tool runs with stale memory or mixed roles
Symptom: tools use inputs from the wrong branch or user/system text leaks.
Fix: split namespaces and enforce state keys.
Open: memory_fences_and_state_keys.md. -
Injection forces the wrong tool
Symptom: argument hijack, tool call not justified by the question.
Fix: hard filters, reasoning-before-action, and schema echo.
Open: anti_prompt_injection_recipes.md, prompt-injection.md. -
Long chains drift then collapse
Symptom: entropy rises after 25–40 steps, answers alternate across runs.
Fix: split the plan, add a BBCR bridge, clamp variance with BBAM, and shorten hops.
Open: context-drift.md, entropy-collapse.md, logic-collapse.md.
Timeouts and backoff rules
- Choose tool timeouts from data, not guesswork
timeout_sec = ceil(p95_latency × 1.5). - Retry only safe operations
Idempotent reads: up to 2 retries with full jitter.
Writes or side effects: no automatic retry; hand off to a queue with a dedupe key. - Global caps
Max concurrent tool calls per plan. Trip a circuit breaker when error rate or queue depth crosses your threshold. - Queue hygiene
Require a dedupe key likesha256(tool_name + args_hash + mem_rev)and drop duplicates.
Reference: retry_backoff.md, rate_limit_backpressure.md.
Implementation checklist
- Tool justification required in JSON:
why_tool,evidence,expected_ΔS_drop. - Strict schemas for arguments with field types and ranges.
- Idempotency and dedupe before side effects.
- Per-tool timeout and retry policy stored near the tool spec.
- Observability: log
ΔS,λ_state, tool name, arguments hash, latency, retries, breaker state. - Post-step audit: citation exists and aligns with the retrieved snippet.
Specs: retrieval-traceability.md, data-contracts.md.
Copy-paste prompt for the tool-selection step
You have TXT OS and the WFGY Problem Map loaded.
Task: choose the next tool or no-tool with a short justification and safe timeouts.
Inputs:
* question: "{user\_question}"
* retrieved: \[{snippet\_id, section\_id, source\_url, offsets, tokens}]
* metrics: ΔS(question,retrieved)=..., λ\_state="→|←|<>|×", p95\_latencies={tool: seconds}
Do:
1. If ΔS ≥ 0.60, prefer retrieval repair over tool calls.
2. Propose one action among {no\_tool, retrieve\_more, rerank, call\_tool\_X}.
3. If choosing a tool, return JSON:
{
"tool": "name",
"why\_tool": "one line using evidence from retrieved",
"args": {...},
"timeout\_sec": ceil(p95\_latencies\[name] \* 1.5),
"retries": 0|1|2,
"idempotent": true|false
}
4. Enforce cite-then-explain in the final answer and log ΔS and λ\_state.
🔗 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.
⭐ WFGY Engine 2.0 is already unlocked. ⭐ Star the repo to help others discover it and unlock more on the Unlock Board.