Loading...
Loading...
Inspect the complete runtime context of any registered agent. The Context Viewer provides real-time state snapshots, policy evaluation history, memory contents, recent actions, and configuration details. Use it for debugging, auditing, and understanding agent behavior.
The context viewer organizes agent state into inspectable sections. Each section can be queried independently via the API.
Current policy evaluation results including active rules, allowed actions, and enforcement decisions.
In-flight policy evaluations with real-time status, input parameters, and intermediate results.
Timeline of recent agent actions with timestamps, outcomes, and policy decisions applied.
Agent working memory including conversation context, accumulated knowledge, and decision history.
Current agent configuration including model parameters, tool access, and rate limits.
Retrieve the complete runtime context of an agent in a single API call.
curl "https://api.drd.io/v1/agents/01956abc-def0/context" \
-H "Authorization: Bearer drd_ws_..."
// Response
{
"agentId": "01956abc-def0...",
"agentName": "Content Scanner v2",
"snapshotAt": "2026-02-14T10:30:00Z",
"status": "active",
"healthStatus": "healthy",
"memory": {
"working": {
"currentTask": "Scanning batch #4521",
"itemsProcessed": 142,
"itemsRemaining": 58,
"startedAt": "2026-02-14T10:25:00Z"
},
"longTerm": {
"totalEntries": 2847,
"sizeBytes": 1245000,
"lastUpdated": "2026-02-14T10:29:45Z",
"categories": {
"contentFingerprints": 1200,
"policyDecisions": 1400,
"userPreferences": 247
}
},
"conversation": {
"activeSessions": 3,
"totalMessages": 847,
"avgSessionLength": 12
}
},
"actions": {
"recent": [
{
"id": "act_01abc...",
"type": "content.scan",
"status": "completed",
"startedAt": "2026-02-14T10:29:50Z",
"completedAt": "2026-02-14T10:29:52Z",
"durationMs": 2100,
"result": { "clean": true }
}
],
"pending": [
{
"id": "act_02def...",
"type": "content.scan",
"status": "queued",
"queuedAt": "2026-02-14T10:30:00Z",
"priority": 5
}
],
"stats": {
"last24h": { "total": 1420, "succeeded": 1415, "failed": 5 }
}
},
"policies": {
"active": [
{
"id": "pol_01abc...",
"name": "Content Scan Rate Limit",
"enabled": true,
"lastEvaluated": "2026-02-14T10:29:50Z"
}
],
"recentEvaluations": [
{
"policyId": "pol_01abc...",
"outcome": "allowed",
"confidence": 0.98,
"evaluatedAt": "2026-02-14T10:29:50Z"
}
]
},
"config": {
"provider": "anthropic",
"model": "claude-opus-4-6",
"version": "2.1.0",
"capabilities": ["content-analysis", "image-classification"],
"tags": ["production", "content-team"],
"rateLimit": { "requestsPerMinute": 1000 },
"timeout": { "defaultMs": 30000, "maxMs": 120000 }
}
}Inspect an agent's memory contents in detail. Supports filtering by memory type, category, and time range.
import { DRDClient } from "@drd/sdk";
const drd = new DRDClient({ apiKey: process.env.DRD_API_KEY! });
// Get working memory
const workingMemory = await drd.agents.context.memory("01956abc-def0...", {
type: "working",
});
console.log("Current task:", workingMemory.currentTask);
console.log("Variables:", Object.keys(workingMemory.variables));
// Get long-term memory entries
const { data: memories } = await drd.agents.context.memory("01956abc-def0...", {
type: "longTerm",
category: "contentFingerprints",
limit: 50,
sortBy: "updatedAt",
order: "desc",
});
for (const entry of memories) {
console.log(entry.key, entry.value, entry.updatedAt);
}
// Search memory by key pattern
const results = await drd.agents.context.searchMemory("01956abc-def0...", {
query: "fingerprint:image/*",
type: "longTerm",
limit: 25,
});
for (const result of results.matches) {
console.log(result.key, result.relevance, result.value);
}View recent and pending actions with execution status and policy evaluation details.
// Get recent actions with details
const { data: actions } = await drd.agents.context.actions("01956abc-def0...", {
status: "completed",
from: "2026-02-14T00:00:00Z",
limit: 50,
});
for (const action of actions) {
console.log(action.id, action.type, action.status);
console.log(" Duration:", action.durationMs, "ms");
console.log(" Result:", JSON.stringify(action.result));
// Check if a policy evaluation was involved
if (action.policyDecision) {
console.log(" Policy:", action.policyDecision.policyName);
console.log(" Outcome:", action.policyDecision.outcome);
}
}
// Get pending actions (queued or in-progress)
const { data: pending } = await drd.agents.context.actions("01956abc-def0...", {
status: "pending",
});
console.log("Pending actions:", pending.length);
for (const action of pending) {
console.log(action.id, action.type, action.priority, action.queuedAt);
}View the history of policy evaluations for a specific agent. Each evaluation includes the full decision trace showing which policies were checked, which rules matched, and the evaluation context.
// Get active policies for an agent
const policies = await drd.agents.context.policies("01956abc-def0...");
for (const policy of policies.active) {
console.log(policy.id, policy.name, policy.enabled);
console.log(" Rules:", policy.ruleCount);
console.log(" Last evaluated:", policy.lastEvaluated);
console.log(" Evaluation count:", policy.evaluationCount);
}
// Get recent policy evaluations
const { data: evaluations } = await drd.agents.context.policyEvaluations(
"01956abc-def0...",
{
outcome: "denied",
from: "2026-02-13T00:00:00Z",
limit: 25,
}
);
for (const eval_ of evaluations) {
console.log(eval_.policyId, eval_.policyName, eval_.outcome);
console.log(" Confidence:", eval_.confidence);
console.log(" Matched rule:", eval_.matchedRule);
console.log(" Context:", JSON.stringify(eval_.context));
}View agent configuration and track configuration changes over time.
// Get agent configuration
const config = await drd.agents.context.config("01956abc-def0...");
console.log("Provider:", config.provider);
console.log("Model:", config.model);
console.log("Version:", config.version);
console.log("Capabilities:", config.capabilities);
console.log("Tags:", config.tags);
console.log("Rate limit:", config.rateLimit.requestsPerMinute, "req/min");
// Get configuration change history
const { data: changes } = await drd.agents.context.configHistory(
"01956abc-def0...",
{ limit: 10 }
);
for (const change of changes) {
console.log(change.timestamp, change.changedBy);
console.log(" Field:", change.field);
console.log(" Old:", JSON.stringify(change.oldValue));
console.log(" New:", JSON.stringify(change.newValue));
}Create and retrieve point-in-time snapshots of an agent's complete context. Snapshots are useful for debugging incidents, comparing state before and after changes, and creating restore points.
import { DRD } from '@drd/sdk';
const drd = new DRD({ apiKey: process.env.DRD_API_KEY });
// Create a snapshot
const snapshot = await drd.agents.context.createSnapshot("01956abc-def0...", {
reason: "Pre-deployment checkpoint",
tags: ["v2.1.0", "pre-deploy"],
});
console.log("Snapshot ID:", snapshot.id);
console.log("Created at:", snapshot.createdAt);
console.log("Size:", snapshot.sizeBytes, "bytes");
// List snapshots
const { data: snapshots } = await drd.agents.context.listSnapshots(
"01956abc-def0...",
{ limit: 10 }
);
for (const snap of snapshots) {
console.log(snap.id, snap.reason, snap.createdAt, snap.tags);
}
// Compare two snapshots
const diff = await drd.agents.context.diffSnapshots(
"01956abc-def0...",
"snap_01abc...",
"snap_02def..."
);
console.log("Changes:");
for (const change of diff.changes) {
console.log(` ${change.path}: ${change.type}`);
if (change.type === "modified") {
console.log(` Old: ${JSON.stringify(change.oldValue)}`);
console.log(` New: ${JSON.stringify(change.newValue)}`);
}
}
// Restore from snapshot
await drd.agents.context.restoreSnapshot("01956abc-def0...", "snap_01abc...", {
sections: ["memory", "state"],
dryRun: false,
});Snapshot limits: Each agent can store up to 100 snapshots. Snapshots older than 90 days are automatically archived to cold storage. Archived snapshots take up to 5 minutes to retrieve.
Subscribe to real-time context changes via Server-Sent Events (SSE). Useful for building live dashboards and monitoring tools.
// Subscribe to context changes
const stream = drd.agents.context.stream("01956abc-def0...", {
sections: ["actions", "memory", "policies"],
});
stream.on("action.started", (event) => {
console.log("Action started:", event.actionId, event.type);
});
stream.on("action.completed", (event) => {
console.log("Action completed:", event.actionId, event.durationMs, "ms");
});
stream.on("memory.updated", (event) => {
console.log("Memory updated:", event.key, event.type);
});
stream.on("policy.evaluated", (event) => {
console.log("Policy evaluated:", event.policyName, event.outcome);
});
stream.on("error", (error) => {
console.error("Stream error:", error);
});
// Close stream when done
stream.close();Compare two snapshots side-by-side to identify what changed in an agent's state between two points in time.
// Compare two snapshots
const diff = await drd.agentContext.compare({
snapshotIdA: 'snap_before',
snapshotIdB: 'snap_after',
});
// Analyze differences
console.log(diff.snapshotA.policyState);
console.log(diff.snapshotB.policyState);