Skip to content

[P3] Context, Artifacts & Reviewable Output - ContextCompiler, ArtifactLedger, Prompt Delta Storage #367

Description

@XuPeng-SH

Problem Statement

Astra needs to treat context as a compiled artifact, not accidental concatenation. Large tool outputs should be referenced, not pushed raw into prompts. Reviewable output (diffs, test reports, artifacts) should be first-class.

Proposed Solution

Implement the context compilation, artifact management, and reviewable output layer:

Core Components

  1. ContextCompiler - Pipeline from candidates to manifest:

    Candidates -> Rank -> Budget zones -> Render -> Hash -> Manifest -> PromptRequestRecord
    
    • Zones: system, policy, workspace, plan/todo, recent tail, retrieved facts, tool previews, artifacts, skills, tool schemas
    • Dropped items recorded with reason and recovery reference
  2. Prompt Request Record - Delta-aware LLM request storage:

    • renderer_version, model_profile, base_prompt_ref, delta_refs[]
    • chunk_hashes[], token_counts_by_zone, redaction_policy_hash, rendered_hash
    • Split stable zones into content-addressed chunks
    • Record per-turn deltas: user input, assistant tail, tool result preview, workspace diff
  3. ArtifactLedger - All large outputs become artifacts:

    • Full tool stdout/stderr, patches/diffs, screenshots, test reports
    • Sandbox data diffs, generated files, context manifests, replay bundles
    • Hot preview metadata + colder full bodies
  4. Tool Result Quality Firewall:

    • Empty, stale, partial, sentinel, over-large outputs flagged
    • Summary + ref instead of raw blob in prompt
  5. Progressive Loading Tools:

    • artifact.fetch, session_history_search, session_history_around, todo.expand
    • Enable low-context models and long-running sessions
  6. Tool Schema Budget Optimization:

    • Full, compact, deferred, hidden schemas
    • Model-window profiles
  7. Reviewable Output Model:

    • Diff, test report, artifact bundle, decision log, PR-ready summary
    • Cloud repo branch lifecycle: checkout, patch, commit, push branch, PR
  8. SDK/Webhook Protocol:

    • Background run creation, wait resolution, artifact review, external approval

Implementation Checklist

  • Implement ContextCompiler with configurable zones and budgets
  • Add tool schema budget optimization
  • Add progressive loading tools
  • Build ArtifactLedger with preview + cold storage
  • Add Tool Result Quality Firewall
  • Add cloud repo branch lifecycle
  • Add reviewable output model
  • Add model-routing profiles for low-context, background, review runs
  • Add state conflict resolution for concurrent edits
  • Add SDK/webhook protocol

Acceptance Criteria

  1. Context manifest shows every included/dropped item with reason
  2. Large tool outputs stored as artifacts, summarized in prompt
  3. Prompt delta storage avoids duplicating stable chunks
  4. Tool schema budgets configurable per model
  5. Progressive loading tools work for long sessions
  6. Reviewable outputs include diffs, test reports, artifacts
  7. SDK/webhook can trigger and respond to runs

Dependencies

References

  • Architecture doc: plans/web-agent-architecture-roi-todos-2026-05-18.md
  • Section: "P3: Context, artifact, and reviewable output" (items 31-43)
  • Section: "Vertical slice D: fork/replay/debug"
  • Section: "Treat context as a compiled artifact"

Non-Goals

  • Do NOT implement full debugger here (P5)
  • Do NOT implement skill evolution here (P6)
  • Do NOT implement tri-layer checkpoint here (P5)
  • Do NOT implement automatic memory promotion here (P6)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions