What is Upsert Runtime Values?
upsert_runtime_values is a specialized tool for writing runtime variables explicitly during workflow execution.
It is useful when the agent should do more than simply observe or extract text. Instead, it should store structured values that later workflow steps can reuse.
In prompts, always refer to this tool as
upsert_runtime_values exactly.When to Use It
Useupsert_runtime_values when you want to:
- store a discovered value like
{{report_path}} - set a failure or status flag like
{{missing_file}} - accumulate arrays or objects across repeated steps
- merge structured data discovered in different phases of a workflow
- saving a discovered export path for later
mark_file_for_export - recording that a required file or patient was not found
- building up an
{{orders}}array across loop iterations - merging multiple extracted sections into one
{{report_data}}object
Where It Is Available
upsert_runtime_values is not a general-purpose main-agent action.
You will most commonly use it in:
focused_actionextract_promptflows, especially async extraction agents
upsert_runtime_values as part of its work.
Basic Usage
The tool accepts JSON-like structured values keyed by runtime-variable name. Conceptually:{{report_path}}{{missing_file}}
Common Prompt Patterns
Save a Discovered Value
Record a Failure Flag
Store Data During Extract Prompt
Array and Object Operations
upsert_runtime_values also supports Mongo-style operators for accumulating structured data instead of replacing it wholesale.
| Operator | Description | Example |
|---|---|---|
$append | Append item to array | {"items": {"$append": "new_item"}} |
$prepend | Prepend item to array | {"items": {"$prepend": "first"}} |
$concat | Concatenate arrays | {"items": {"$concat": ["a", "b"]}} |
$merge | Shallow merge objects | {"config": {"$merge": {"key": "val"}}} |
$remove | Remove first occurrence by value | {"tags": {"$remove": "old"}} |
$pop | Remove last element | {"stack": {"$pop": true}} |
Example: Accumulating Across a Loop
Example: Merging Structured Sections
Best Practices
- Use clear runtime variable names like
{{report_path}}or{{missing_file}}. - Prefer booleans for simple failure flags.
- Use
$appendand$mergeinstead of replacing large objects repeatedly. - Only store values you actually need later in the workflow or output.
- If a missing value should stop the run, pair
upsert_runtime_valueswithdeclare_task_failed.