WFGY/ProblemMap/GlobalFixMap/PromptAssembly/tool_selection_and_timeouts.md

11 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

Layer Page What its for
Proof WFGY Recognition Map External citations, integrations, and ecosystem proof
⚙️ Engine WFGY 1.0 Original PDF tension engine and early logic sketch (legacy reference)
⚙️ Engine WFGY 2.0 Production tension kernel for RAG and agent systems
⚙️ Engine WFGY 3.0 TXT based Singularity tension engine (131 S class set)
🗺️ Map Problem Map 1.0 Flagship 16 problem RAG failure taxonomy and fix map
🗺️ Map Problem Map 2.0 Global Debug Card for RAG and agent pipeline diagnosis
🗺️ Map Problem Map 3.0 Global AI troubleshooting atlas and failure pattern map
🧰 App TXT OS .txt semantic OS with fast bootstrap
🧰 App Blah Blah Blah Abstract and paradox Q&A built on TXT OS
🧰 App Blur Blur Blur Text to image generation with semantic control
🏡 Onboarding Starter Village Guided entry point for new users

If this repository helped, starring it improves discovery so more builders can find the docs and tools.
GitHub Repo stars