# Cloud context search

Search cloud organizational memory and return ranked, compact context for agents.

Capability: op_sys_cloud_context_search
Protocol: op-sys.capabilities.v1
Runtime: 0.3.0
Availability: Local or configured shared service
Optional integration: true
Canonical page: /docs/reference/op_sys_cloud_context_search

## Authority

Local event queries use the selected private state root. Cloud queries use tenant credentials, scopes and payload policy. This event surface is distinct from generic record collections.

## Invocation

CLI, SDK and MCP use the same operation and arguments; where a hosted HTTP binding exists, its route carries the same domain contract. Host paths and environment references refer to the runtime host. Request template: replace placeholder IDs and supply complete contract-specific objects before use. This is not a complete runnable workflow.

### CLI

```sh
op-sys --output json tools call op_sys_cloud_context_search \
  --arguments '{"query":"<query>"}'
```

### Python SDK

```python
import json
from op_sys import OpSys

client = OpSys()
arguments = json.loads("{\"query\":\"<query>\"}")
result = client.capabilities.call(
    "op_sys_cloud_context_search", arguments
)
print(result)
```

### MCP (initialized connection)

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "op_sys_cloud_context_search",
    "arguments": {
      "query": "<query>"
    }
  }
}
```

## Parameters

### query

Required; string. Natural language or keyword query, for example checkout failures.



### source_id

Optional; string. Stable cloud source identity.



### ledger_id

Optional; string. Local ledger label to filter by.



### namespace

Optional; string. Cloud aggregation namespace.



### entity_id

Optional; string. Entity id filter.



### entity_type

Optional; string. Entity type filter.



### workflow

Optional; string. Workflow namespace filter.



### actor

Optional; string. Actor id filter.



### since

Optional; string. Cloud timestamp lower bound.



### payload

Optional; string. Consumer-defined JSON value validated against the selected admitted contract.

Schema default: "metadata". Send null only if the input schema permits it.

Allowed: "metadata", "full"

### limit

Optional; integer. 

Schema default: 20. Send null only if the input schema permits it.

minimum: 1; maximum: 500

### max_text_chars

Optional; integer. 

Schema default: 12000. Send null only if the input schema permits it.

minimum: 1000; maximum: 50000

### cursor

Optional; string. Opaque Cloud continuation; reuse the same filters and limit. Restart explicitly after expiry or invalidation.

maxLength: 8192

### Complete input schema

```json
{
  "type": "object",
  "properties": {
    "query": {
      "type": "string",
      "description": "Natural language or keyword query, for example checkout failures."
    },
    "source_id": {
      "type": "string",
      "description": "Stable cloud source identity."
    },
    "ledger_id": {
      "type": "string",
      "description": "Local ledger label to filter by."
    },
    "namespace": {
      "type": "string",
      "description": "Cloud aggregation namespace."
    },
    "entity_id": {
      "type": "string",
      "description": "Entity id filter."
    },
    "entity_type": {
      "type": "string",
      "description": "Entity type filter."
    },
    "workflow": {
      "type": "string",
      "description": "Workflow namespace filter."
    },
    "actor": {
      "type": "string",
      "description": "Actor id filter."
    },
    "since": {
      "type": "string",
      "description": "Cloud timestamp lower bound."
    },
    "payload": {
      "type": "string",
      "enum": [
        "metadata",
        "full"
      ],
      "default": "metadata"
    },
    "limit": {
      "type": "integer",
      "minimum": 1,
      "maximum": 500,
      "default": 20
    },
    "max_text_chars": {
      "type": "integer",
      "minimum": 1000,
      "maximum": 50000,
      "default": 12000
    },
    "cursor": {
      "type": "string",
      "maxLength": 8192,
      "description": "Opaque Cloud continuation; reuse the same filters and limit. Restart explicitly after expiry or invalidation."
    }
  },
  "required": [
    "query"
  ],
  "additionalProperties": false
}
```

## Behavior

- Context search ranks retained event text; it does not automatically reason over your organization.
- Local and Cloud continuation formats are independent. Keep filters, scope and effective limit stable; never reuse a cursor across scopes.
- Metadata is the default for Cloud payload selection. Full payloads require the relevant raw-content permission.

## Response

Returns the native query or diagnostic payload. See the event-query and output manuals for field semantics.

[Runtime output field catalog](/docs/output-contracts.json) (descriptive contracts, not JSON Schema validators).

CLI: use --output json. For tools call, read the operation result at payload.tool.result; payload.tool.name identifies the capability. The outer envelope is {schema_version: "v1", payload: {tool: {name, result}}}.

Python: client.capabilities.call(name, arguments) returns the operation result. SDK exceptions preserve reason and code.

MCP: tools/call returns JSON text and structuredContent. Application failures set isError; inspect reason/code instead of matching message text.

No standalone response JSON Schema is published for this operation. The input schema is not a response contract.

## Errors and recovery



Family reasons are representative, not exhaustive.

A timeout is not proof that a write failed. Reuse the documented retry identity, batch, offset or mutation ID. If this operation has no documented retry identity, inspect its state before repeating it.

On authorization failure, correct the configured identity or grants; do not change the local actor to impersonate a hosted principal. On validation failure, correct the input against the published schema and selected contract.

On a revision or state conflict, retrieve current state and reconcile intent. Do not automatically overwrite a competing update. Preserve unknown additive response fields when building consumers.

## Source manuals

- [local-query](/docs/raw/manuals/local-query.md)
- [cloud-client](/docs/raw/manuals/cloud-client.md)
- [command-output-schema](/docs/raw/manuals/command-output-schema.md)
- [public-capabilities](/docs/raw/manuals/public-capabilities.md)
