Skip to content

Commit 8a8e0b2

Browse files
committed
dev-demo: add agent checkpoints resource and update turns with checkpoint_id
1 parent 577c0cf commit 8a8e0b2

7 files changed

Lines changed: 90 additions & 0 deletions

File tree

dev-demo/globalPlugins.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,23 @@ export const globalPlugins = [
7373
promptField: 'prompt',
7474
responseField: 'response',
7575
debugField: 'dubbug',
76+
checkpointIdField: 'checkpoint_id',
77+
},
78+
checkpointResource: {
79+
resourceId: 'agent_checkpoints',
80+
idField: 'id',
81+
threadIdField: 'thread_id',
82+
checkpointNamespaceField: 'checkpoint_namespace',
83+
checkpointIdField: 'checkpoint_id',
84+
parentCheckpointIdField: 'parent_checkpoint_id',
85+
rowKindField: 'row_kind',
86+
taskIdField: 'task_id',
87+
sequenceField: 'sequence',
88+
createdAtField: 'created_at',
89+
checkpointPayloadField: 'checkpoint_payload',
90+
metadataPayloadField: 'metadata_payload',
91+
writesPayloadField: 'writes_payload',
92+
schemaVersionField: 'schema_version',
7693
},
7794
audioAdapter: new OpenAIAudioAdapter({
7895
apiKey: process.env.OPENAI_API_KEY as string,

dev-demo/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import auditLogsResource from "./resources/auditLogs.js"
2626
import sessionsResource from "./resources/agent_resources/sessions.js";
2727
import dashboardConfigsResource from './resources/dashboard_configs.js';
2828
import turnsResource from './resources/agent_resources/turns.js';
29+
import checkpointsResource from './resources/agent_resources/checkpoints.js';
2930
import { FICTIONAL_CAR_BRANDS, FICTIONAL_CAR_MODELS_BY_BRAND, ENGINE_TYPES, BODY_TYPES } from './custom/cars_data.js';
3031
import passkeysResource from './resources/passkeys.js';
3132
import carsDescriptionImage from './resources/cars_description_image.js';
@@ -147,6 +148,7 @@ export const admin = new AdminForth({
147148
background_jobs_resource,
148149
sessionsResource,
149150
turnsResource,
151+
checkpointsResource,
150152
dashboardConfigsResource,
151153
adminExternalIdentitiesResource,
152154
key_value_resource,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE "turns" ADD COLUMN "checkpoint_id" TEXT;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- CreateTable
2+
CREATE TABLE "agent_checkpoints" (
3+
"id" TEXT NOT NULL PRIMARY KEY,
4+
"thread_id" TEXT NOT NULL,
5+
"checkpoint_namespace" TEXT NOT NULL,
6+
"checkpoint_id" TEXT NOT NULL,
7+
"parent_checkpoint_id" TEXT,
8+
"row_kind" TEXT NOT NULL,
9+
"task_id" TEXT,
10+
"sequence" INTEGER NOT NULL,
11+
"created_at" DATETIME NOT NULL,
12+
"checkpoint_payload" TEXT,
13+
"metadata_payload" TEXT,
14+
"writes_payload" TEXT,
15+
"schema_version" INTEGER NOT NULL
16+
);

dev-demo/migrations/prisma/sqlite/schema.prisma

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,23 @@ model turns {
132132
prompt String?
133133
response String?
134134
dubbug String?
135+
checkpoint_id String?
136+
}
137+
138+
model agent_checkpoints {
139+
id String @id
140+
thread_id String
141+
checkpoint_namespace String
142+
checkpoint_id String
143+
parent_checkpoint_id String?
144+
row_kind String
145+
task_id String?
146+
sequence Int
147+
created_at DateTime
148+
checkpoint_payload String?
149+
metadata_payload String?
150+
writes_payload String?
151+
schema_version Int
135152
}
136153

137154
model dashboard_configs {
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { AdminForthDataTypes } from 'adminforth';
2+
import type { AdminForthResourceInput } from 'adminforth';
3+
4+
// Persistent LangGraph checkpointer store for the AdminForth Agent plugin.
5+
// Enables reliable multi-turn memory and message editing / branching.
6+
export default {
7+
dataSource: 'sqlite',
8+
table: 'agent_checkpoints',
9+
resourceId: 'agent_checkpoints',
10+
label: 'Agent Checkpoints',
11+
columns: [
12+
{ name: 'id', primaryKey: true, type: AdminForthDataTypes.STRING },
13+
{ name: 'thread_id', type: AdminForthDataTypes.STRING },
14+
{ name: 'checkpoint_namespace', type: AdminForthDataTypes.STRING },
15+
{ name: 'checkpoint_id', type: AdminForthDataTypes.STRING },
16+
{ name: 'parent_checkpoint_id', type: AdminForthDataTypes.STRING },
17+
{ name: 'row_kind', type: AdminForthDataTypes.STRING },
18+
{ name: 'task_id', type: AdminForthDataTypes.STRING },
19+
{ name: 'sequence', type: AdminForthDataTypes.INTEGER },
20+
{ name: 'created_at', type: AdminForthDataTypes.DATETIME },
21+
{ name: 'checkpoint_payload', type: AdminForthDataTypes.TEXT },
22+
{ name: 'metadata_payload', type: AdminForthDataTypes.TEXT },
23+
{ name: 'writes_payload', type: AdminForthDataTypes.TEXT },
24+
{ name: 'schema_version', type: AdminForthDataTypes.INTEGER },
25+
],
26+
} as AdminForthResourceInput;

dev-demo/resources/agent_resources/turns.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,16 @@ export default {
5959
filter: false,
6060
},
6161
},
62+
{
63+
name: 'checkpoint_id',
64+
type: AdminForthDataTypes.STRING,
65+
showIn: {
66+
list: false,
67+
show: true,
68+
edit: false,
69+
create: false,
70+
filter: false,
71+
},
72+
},
6273
],
6374
} as AdminForthResourceInput;

0 commit comments

Comments
 (0)