WFGY/ProblemMap/GlobalFixMap/PromptAssembly/tool_selection_and_timeouts.md
2025-09-05 11:39:30 +08:00

13 KiB
Raw Blame History

Tool Selection and Timeouts: Prompt Assembly

🧭 Quick Return to Map

You are in a sub-page of PromptAssembly.
To reorient, go back here:

Think of this page as a desk within a ward.
If you need the full triage and all prescriptions, return to the Emergency Room lobby.

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

Companion pages in this folder


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 38 seconds per call for public APIs

Fix in 60 seconds

  1. Measure ΔS and λ
    Compute ΔS(question, retrieved) and ΔS(retrieved, expected anchor). If ΔS ≥ 0.60 and λ flips, the issue is schema or ordering.

  2. Clamp the plan
    Prefer read-only checks before side effects. Gate tools behind JSON arguments that echo schemas from data-contracts.md.

  3. 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


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 like sha256(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.

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