Fix Agent Help Trail Availability

Pi·GPT-5.6-sol·dipree·2mo ago·2hr 49min·5 Checkpoints·26 file changes·+516/-86·164.2K tokens

agent-help trail is claiming trails is not available but it should actually check the availability of it. The reason it says that is becaue the feature is not generally available but we do have an elaborate check whether trails is enabled for a repo and we should just use that instead of saying it's not available.

2mo ago·5.1s

Implemented the trails availability fix.

  • entire agent-help now refreshes missing or stale repo-specific trails enablement before deciding availability.
  • Uses the existing cached/API enablement mechanism with a bounded timeout.
  • Added regression coverage for an unknown cache becoming enabled.
  • Full ./cmd/entire/cli test suite passes.

Create a PR

2mo ago·6.1s

Commit/push

2mo ago·4.3s

Committed, pushed, and created PR:

https://github.com/entireio/cli/pull/1762

Does this make any sense?

"This refresh call gives entire agent-help (and the agent_help MCP tool via mcp.go:221) a hard network/auth dependency it previously didn't have: refreshTrailsEnabledCacheIfStaleForScope → NewAuthenticatedAPIClient → auth.ResolveDataAPIToken always performs a /.well-known/entire-api.json discovery GET before it even checks whether any login context exists, so on a cold cache (first run, or hourly TTL expiry) agent-help can now block for up to the full trailEnablementRefreshTimeout (3s) whenever the user is offline or not yet logged in — exactly the situation where an agent is most likely to reach for agent-help as a first step. Previously this call was cache-only and instant regardless of auth/network state. Consider keeping the fast cache-only read as the default for agent-help and only triggering the network refresh in a non-blocking/best-effort way (as refreshTrailsEnabledCacheBestEffort already does elsewhere), or shortening/bounding this specific path more aggressively."

2mo ago·22.5s

Yes—mostly.

The review correctly identifies a latency regression:

  • On a missing/stale cache, agent-help and MCP synchronously perform auth discovery and an API probe.
  • Offline users can wait up to 3 seconds.
  • Users with no login context may still incur discovery before auth fails.

Two nuances:

  • It is not a hard functional dependency: refresh errors are swallowed and help still renders. It is a synchronous latency dependency.
  • refreshTrailsEnabledCacheBestEffort is also synchronous; “best effort” does not make it non-blocking.

Keeping agent-help cache-only would recreate the original bug. Better mitigations are:

  1. Skip refresh immediately when scope.AuthKey == "".
  2. Probe primarily for explicit trail help requests.
  3. Use a shorter agent-help-specific timeout.
  4. Report availability as unknown rather than “not enabled” when probing fails.

Probably 1 should help with most of this?

2mo ago·7.5s

Yes. scope.AuthKey == "" reliably indicates no local login identity, so skipping refresh avoids the worst first-run case without reintroducing the original bug for authenticated users.

Offline-but-logged-in users could still wait up to 3 seconds on stale cache, but that is less common and necessary to obtain a fresh answer. I’d implement option 1 and keep the bounded refresh for authenticated users.

Do it

2mo ago·9.4s

Implemented and pushed to PR #1762.

  • Skips trails refresh when no local auth identity exists.
  • Added regression coverage ensuring no refresh/network path is invoked.
  • Full CLI package tests pass.

Entire Trail review comment ID: 019f65e8-e907-7f5e-b401-c2cbb611404c URL: https://entire.io/gh/entireio/cli/trails/864/fix-agent-help-refresh-trails-availability Severity: medium Context: cmd/entire/cli/agent_help_cmd.go:102 Selected context:

agentHelpRepoContextWithRefresh now makes entire agent-help do a network round trip (via refreshTrailsEnabledCacheIfStaleForScopeNewAuthenticatedAPIClientauth.ResolveDataAPIToken) whenever the local trails cache is unknown/stale and the user is logged in, blocking for up to trailEnablementRefreshTimeout (3s). If that call fails (e.g. offline, DNS/API discovery failure), refreshTrailsEnabledCacheIfStaleForScope returns an error without writing anything to the cache, so the decision stays trailEnablementCacheUnknown and every subsequent agent-help invocation repeats the same blocking network attempt instead of negatively caching the failure — turning a previously instant, offline-safe introspection command into one with a recurring multi-second stall on every call in degraded-network environments.

2mo ago·49.6s

Addressed and pushed to PR #1762.

  • Failed refreshes now create a five-minute negative cache.
  • Repeated agent-help calls avoid recurring three-second stalls.
  • Definitive disabled results retain the normal one-hour TTL.
  • Added regression coverage for failure backoff and retry expiry.
  • Full CLI and settings tests pass.

Entire Trail review comment ID: 019f65f0-e225-7982-a723-a851bb95f596 URL: https://entire.io/gh/entireio/cli/trails/864/fix-agent-help-refresh-trails-availability Severity: medium Context: cmd/entire/cli/agent_help_cmd.go:111 Selected context:

agentHelpRepoContextWithRefresh now writes to the shared trails-enablement cache (.entire clone preferences) on a failed refresh, which previously only SessionStart/trail commands ever mutated. refreshTrailsEnabledCacheIfStaleForScope (called from lifecycle.go at SessionStart) treats any non-trailEnablementCacheUnknown cache entry as fresh and skips its own refresh — so a transient failure surfaced only by an entire agent-help call can plant a 5-minute-backoff "disabled" entry that suppresses SessionStart's real probe. If emitContextInjection finalizes ContextInjectionDecided during that window it locks in disabled for the rest of the session (it never re-checks once decided), even though trails may actually be enabled and reachable moments later.

2mo ago·35.8s

Addressed and pushed.

The five-minute failure backoff is now stored separately from the shared trails-enablement decision. Therefore:

  • Repeated agent-help calls still avoid network stalls.
  • SessionStart continues its authoritative probe.
  • Context injection is never finalized as disabled due to an agent-help network failure.

Tests verify the shared cache remains unknown after failure.

Linter is failing...

2mo ago·6.7s

Fixed and pushed.

CI reported:

  • Unchecked saveAgentHelpTrailsRefreshFailure error — now debug-logged.
  • Repeated "gh/acme/app" test string — replaced with a constant.

Relevant tests pass; CI is rerunning.