Skip to main content
The Action Cache (AC) service stores and retrieves action results, enabling incremental builds by reusing previously computed outputs.

Overview

The Action Cache maps action digests to their execution results, including:
  • Exit code
  • stdout/stderr
  • Output file digests
  • Execution metadata
Key features:
  • Action result caching
  • Read-only mode support
  • Automatic result validation

Configuration

instance_name
string
required
The instance name identifying this AC endpoint
ac_store
string
required
Reference to the store configured in the stores section
read_only
boolean
default:false
If true, only GetActionResult is allowed (no updates)
{
  services: {
    ac: [
      {
        instance_name: "main",
        ac_store: "AC_STORE",
        read_only: false
      }
    ]
  }
}

gRPC Methods

GetActionResult

Retrieve a cached action result. Request:
instance_name
string
required
The instance name
action_digest
Digest
required
Digest of the Action message
inline_stdout
boolean
default:false
Include stdout inline if small enough
inline_stderr
boolean
default:false
Include stderr inline if small enough
inline_output_files
string[]
Paths of output files to include inline
Response:
exit_code
int32
Process exit code
stdout_digest
Digest
Digest of stdout (if not inlined)
stdout_raw
bytes
Inline stdout (if requested and small)
stderr_digest
Digest
Digest of stderr (if not inlined)
stderr_raw
bytes
Inline stderr (if requested and small)
output_files
OutputFile[]
Output files produced by the action
output_directories
OutputDirectory[]
Output directories produced by the action
execution_metadata
ExecutedActionMetadata
Metadata about the execution (worker, timing, etc.)
Example with grpcurl:
grpcurl -plaintext \
  -d '{
    "instance_name": "main",
    "action_digest": {
      "hash": "abc123...",
      "size_bytes": 256
    },
    "inline_stdout": true,
    "inline_stderr": true
  }' \
  localhost:50051 build.bazel.remote.execution.v2.ActionCache/GetActionResult

UpdateActionResult

Store an action result in the cache. Request:
instance_name
string
required
The instance name
action_digest
Digest
required
Digest of the Action message
action_result
ActionResult
required
The result to cache
results_cache_policy
ResultsCachePolicy
Caching policy (priority, etc.)
Response:
action_result
ActionResult
The stored action result (echoed back)
Updates fail with PERMISSION_DENIED if the AC is configured as read-only

Cache Key Structure

The action digest serves as the cache key and is computed from:
  • Command line arguments
  • Environment variables
  • Input file digests
  • Platform properties
The action digest must be deterministic - same inputs always produce the same digest

Implementation Details

From nativelink-service/src/ac_server.rs:
pub struct AcServer {
    stores: HashMap<String, AcStoreInfo>,
}

pub struct AcStoreInfo {
    store: Store,
    read_only: bool,
}
Each instance can have independent read-only settings, allowing shared read-only caches with local read-write overlays.

Error Codes

CodeDescription
NOT_FOUNDAction result not in cache
INVALID_ARGUMENTInvalid action digest or instance name
PERMISSION_DENIEDUpdate attempted on read-only AC
INTERNALStorage backend error
The AC service follows the Remote Execution API v2 specification

Build docs developers (and LLMs) love