Skip to main content
Glama
Cohexa-ai

Agent Coherence — Stale Write Guard (FS)

Official
by Cohexa-ai

swg_read

Read a workspace text file under coherence tracking. Returns {content, version, owner_generation}. The version is the comparand you pass to swg_write_cas; KEEP BOTH version and owner_generation and pass them to swg_gate before any…

Instructions

Read a workspace text file under coherence tracking. Returns {content, version, owner_generation}. The version is the comparand you pass to swg_write_cas; KEEP BOTH version and owner_generation and pass them to swg_gate before any irreversible external action you decide from this read (owner_generation=null means this coordinator does not report generations, so swg_gate will hold). When the path has a handoff record the result also carries handoff: the record as it concerns this session (role giver, successor or bystander, the two session_agent_ids, version_at_transfer, hold_shape, status, live); handoff_unknown=true instead means the read was denied and the record could not be fetched. The coordinator attaches the record best-effort, so a result with neither does not prove there is no record; swg_status lists every record. A sticky-INVALID view returns fresh bytes but stays INVALID — use swg_reacquire to recover before writing. If the bytes on disk are not the content at the current version, the read is DENIED with reason=stale_view and no version. A peer's commit still reaching disk clears on its own: swg_reacquire, then swg_read again, retrying for a few seconds. Only if it stays denied past that was the file changed outside the coordinator (an out-of-band edit, or a commit whose disk write failed): swg_write the content swg_reacquire returned (or your merge of it), then swg_read. A write made sooner can be overwritten by a peer commit still reaching disk. SINGLE-HOST only. Out of guarantee and NOT detected in v1: writers on different hosts or across a synced/network mount, divergent-history reconciliation, semantic correctness, server-enforced auto-merge.

Input Schema

NameRequiredDescriptionDefault
pathYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.12.0

TDQS

A4.5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations supply only readOnlyHint=false, so the description carries the load and does: DENIED with reason=stale_view and no version, sticky-INVALID views returning fresh bytes while staying invalid, handoff/ handoff_unknown semantics, the best-effort attach caveat (absence of a record does not prove none exists), and the explicit single-host scope plus a list of guarantees NOT detected in v1.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The first two sentences are crisply front-loaded (purpose, return shape, next-tool routing), but the remainder is a dense multi-topic run-on covering denial handling, handoff internals, and scope caveats that an agent must parse in one block. Much of it earns its place, yet the wall-of-text structure hurts scannability.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

There is no output schema, and the description compensates fully by naming every returned field, the conditional handoff sub-record, the denial reason, and the boundary conditions of the guarantee. For a coherence-protocol tool, an agent has everything needed to interpret a result and decide the next call.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% for the single 'path' parameter, so the description must compensate. It implies path addresses a workspace file that can be keyed to a handoff record ('when the path has a handoff record'), but gives no format, root, or resolution rules for the value, so it only partially fills the gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with a concrete verb+resource+scope: 'Read a workspace text file under coherence tracking', then names the exact return shape {content, version, owner_generation}. It also positions the tool against siblings (swg_write_cas, swg_gate, swg_status, swg_reacquire), so an agent can distinguish this read from the write/CAS/gate tools without opening schemas.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly instructs what to do with the outputs (keep version and owner_generation and pass them to swg_write_cas/swg_gate before any irreversible external action) and gives a concrete escalation path for stale_view (swg_reacquire, re-read, retry for a few seconds, and only then swg_write). It even flags the ordering hazard that an early write can be overwritten by a peer commit still reaching disk.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.