Skip to content

Add cache-stable agent capability runtime / 新增缓存稳定的 Agent 能力运行时#6623

Closed
SivanCola wants to merge 1 commit into
esengine:main-v2from
SivanCola:feature/agent-capability-upgrade
Closed

Add cache-stable agent capability runtime / 新增缓存稳定的 Agent 能力运行时#6623
SivanCola wants to merge 1 commit into
esengine:main-v2from
SivanCola:feature/agent-capability-upgrade

Conversation

@SivanCola

@SivanCola SivanCola commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Persist a session RuntimeContract for capability surface, edit protocol, and prompt layout.
  • Add stable BM25 capability discovery and proxy execution without mutating provider-visible schemas.
  • Add the session-context prompt layout and deterministic three-level compaction state.
  • Add opt-in Hashline v1 editing with preview confinement and permission aliases.
  • Route dynamic MCP tools to execution and legacy registries while keeping capability schemas stable across connect, disconnect, resume, and lazy cache misses.

Why

Agent sessions previously derived provider-visible tools and prompt layout from process state. Dynamic MCP registration and non-deterministic compaction could change cached prefixes or alter behavior after resume. This change makes those choices session-owned and persisted while preserving the existing default behavior.

Cache and rollout

  • Empty configuration still selects legacy-v1, classic-v1, and system-v1.
  • Enabling the v2 surface or Hashline intentionally causes one cold prefix when a new session starts.
  • Provider-visible capability schemas remain fixed after session creation.
  • Cache guard tail averages remain 92–95 percent across all covered dialogue and tool-loop scenarios.
  • The default switch remains gated on live provider A/B results.

Compatibility

Area Existing behavior or data Result
Pre-contract sidecars No runtime contract Pinned to legacy behavior
Missing transcript sidecar Strict inference, otherwise legacy fallback Compatible
Corrupt sidecar Diagnostic plus legacy fallback Compatible
Session JSON Optional runtime_contract field Compatible
Configuration Missing new fields Legacy defaults
Provider tool schema Legacy unchanged; v2 opt-in Compatible

Validation

  • ./scripts/cache-guard.sh
  • Root module: go test ./..., go vet ./..., go build ./..., and go test -race ./...
  • Desktop module: go test ./..., go vet ./..., go build ./..., and go test -race ./...

Attribution

Hashline is adapted from the xAI grok-build implementation at baseline commit c68e39f under Apache-2.0. The package includes the required license, NOTICE, and adapted-source headers.

Not included

  • Switching the product default to the v2 runtime
  • Desktop new-task editing protocol controls
  • Live provider A/B and the token-reduction release gate

Problem:
Agent sessions lacked a persisted contract for provider-visible tool, edit, and prompt surfaces. Dynamic capability and MCP registration plus compaction state could drift across resume and invalidate cached prefixes.

Root cause:
Runtime choices were process-derived, capability discovery exposed dynamic schemas, and compaction and prompt context did not have deterministic session-owned representations.

Fix:
Introduce persisted runtime contracts, stable capability search and proxy surfaces, a session-context prompt layout, deterministic compaction state, and opt-in Hashline editing. Keep legacy defaults, preserve old-session behavior, and route dynamic MCP tools to execution plus legacy without mutating capability provider schemas.

Verification:
- ./scripts/cache-guard.sh
- go test ./...
- go vet ./...
- go build ./...
- go test -race ./...
- desktop: go test, go vet, go build, and go test -race ./...
@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development tui Terminal UI / CLI (internal/cli, internal/control) skills Skill system (internal/skill, internal/tool) agent Core agent loop (internal/agent, internal/control) mcp MCP servers / plugins (internal/plugin, codegraph) config Configuration & setup (internal/config) provider Model providers & selection (internal/provider) labels Jul 17, 2026
@SivanCola

Copy link
Copy Markdown
Collaborator Author

Closing this draft in favor of #6705, which has merged into main-v2 as 43993f5.

Adopted in the focused replacement:

  • Package-aware MCP/skill runtime bindings and portable-to-canonical tool resolution.
  • Canonical permission, approval, hook, evidence, and audit identities.
  • Exact-ID-restricted on-demand MCP capability proxies for subagents.
  • Live-over-cache precedence, ambiguity rejection, and provider-schema/cache stability guards.

Not adopted from this broader draft:

  • The persisted runtime-contract and opt-in v2 capability surface.
  • The session-context and three-level compaction redesign.
  • Hashline editing and the associated configuration/provider changes.

Those broader experiments remain separate future work. If revisited, they should be split into focused PRs, rebased on current main-v2, and preserve the canonical binding, security-identity, cache-stability, and scoped-proxy contracts now provided by #6705.

Verification for #6705 completed with the full Go test suite, vet, focused race coverage, cache guard, three-platform CI, CodeQL, and desktop builds all passing.

Availability: the focused MCP/skill fix is now on main-v2 and will ship with the next release.

@SivanCola SivanCola closed this Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Core agent loop (internal/agent, internal/control) config Configuration & setup (internal/config) mcp MCP servers / plugins (internal/plugin, codegraph) provider Model providers & selection (internal/provider) skills Skill system (internal/skill, internal/tool) tui Terminal UI / CLI (internal/cli, internal/control) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant