Skip to main content
Back to how-to guides Use this pattern when a target agent must read, or update, a stored value that the calling agent owns.

Concept

Memory belongs to the agent that declares it. A target agent does not see the caller’s stored values. A memory grant gives the target access to named paths for one handoff or one delegate call. A grant has two parts:
  • path names the memory path.
  • access is read or readwrite. The default is read.
Use a grant for stored values. Use PASS for values the caller already holds in the conversation. See Pass specific fields between agents. Grant the fewest paths and the lowest access that the target needs.

Minimal working example

An account router holds a customer ID that all specialists in this conversation tree share. The statement agent needs to read it. The router grants the path read-only. ON_START sets the customer ID to a fixed value as a stand-in. In your project, set it from your sign-in or lookup step. agents/account-hub.agent.abl
agents/statement-agent.agent.abl
The target declares no memory. The grant alone gives it access. The target model sees the value in a “Granted Memory” section of its prompt. Variable sources:
  • workflow.customer_id is persistent memory of the router, set in ON_START.
  • The target receives it under granted_memory.workflow.customer_id.

How it works

When the handoff runs, the runtime resolves each grant, then attaches the value to the target.
  1. The runtime reads the source declaration in the caller. The grant path must match a declared path or the execution_tree. namespace.
  2. The runtime finds the value in this order: the execution tree, the caller’s current values, then the stored user or project value. If no value exists, it uses the declared default.
  3. The runtime attaches the value to the target under granted_memory.<path>. The target does not need to declare the path. If a value is missing, nothing is attached for that path.
  4. The runtime authorizes each path that has a value for the target prompt. The prompt shows these values in a “Granted Memory” section.
  5. When PII protection is on, the runtime tokenizes protectable values first.
  6. A write to a read grant is refused. The runtime reports the reason granted_memory_read_only.
Rules that the compiler enforces: The same rules apply to a DELEGATE MEMORY_GRANTS list.

Common variations

Grant stored user and session values

A route can mix kinds. The session field region needs no access line. The user path is read-only.
This is a section snippet. It needs the router MEMORY declarations user.preferred_language and region.

Let the target update shared memory

Use readwrite only for execution-tree memory that the caller declares with ACCESS: readwrite. The target writes the value with a SET to granted_memory.<path>. agents/verify-agent.agent.abl
The route grants the path with access: readwrite.
The second block is an illustrative fragment of a grant list. The first block is a full document. The value cust-2077 is a stand-in. Set it from your verification step. A SET to a path that has a read grant is refused at run time with the reason granted_memory_read_only. The compiler does not catch it.

Grant memory to a delegate

A DELEGATE uses a MEMORY_GRANTS list on the entry.
This is a section snippet. It needs the caller MEMORY declaration and the Refund_Checker agent from Delegate and map the result.

Verification

  1. Run the validator on both files. Expect no errors and no warnings.
  2. Send “I need my statement.” Answer the month.
  3. Expect a handoff trace event to Statement_Agent.
  4. Open the first model call of Statement_Agent in the trace. Expect a “Granted Memory” section that lists workflow.customer_id.
  5. Remove the memory_grants block and repeat. Expect the section to be missing. Restore the block.
  6. Change the access to readwrite on a user-scoped path. Expect compile error INVALID_HANDOFF_MEMORY_GRANT_ACCESS.

Production readiness checklist

  • Every granted path is declared in the caller.
  • Every grant uses read unless the target must write.
  • Each readwrite grant has a written reason and a test for the write.
  • The target reads or writes each granted path as granted_memory.<path>.
  • The granted data fits the target’s purpose. See Minimize context for privacy and compliance.
  • Tests cover a path that has a value and a path that has none.

Common mistakes

Troubleshooting

Related articles: