Skip to content

Commit 7c7fdb8

Browse files
committed
docs: add checkpoint_id field to agent plugin and update related schema
1 parent 8a8e0b2 commit 7c7fdb8

1 file changed

Lines changed: 33 additions & 19 deletions

File tree

  • adminforth/documentation/docs/tutorial/09-Plugins

adminforth/documentation/docs/tutorial/09-Plugins/01-agent.md

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,17 @@ export default {
139139
name: 'response',
140140
type: AdminForthDataTypes.TEXT,
141141
},
142+
{
143+
name: 'checkpoint_id',
144+
type: AdminForthDataTypes.STRING,
145+
showIn: {
146+
list: false,
147+
show: true,
148+
edit: false,
149+
create: false,
150+
filter: false,
151+
},
152+
},
142153
],
143154
options: {
144155
allowedActions: {
@@ -152,7 +163,7 @@ export default {
152163
} as AdminForthResourceInput;
153164
```
154165

155-
`asker_id` must store the current admin user's primary key, and `created_at` should be filled automatically because the plugin sorts sessions and turns by it. The `turns` field can stay nullable, but the plugin configuration still expects it.
166+
`asker_id` must store the current admin user's primary key, and `created_at` should be filled automatically because the plugin sorts sessions and turns by it. The `turns` field can stay nullable, but the plugin configuration still expects it. The optional `checkpoint_id` field stores the checkpoint attached to each visible turn and enables editing or forking old messages when `checkpointResource` is configured.
156167

157168
Add matching tables to your schema:
158169

@@ -166,11 +177,12 @@ model sessions {
166177
}
167178
168179
model turns {
169-
id String @id
170-
session_id String
171-
created_at DateTime
172-
prompt String?
173-
response String?
180+
id String @id
181+
session_id String
182+
created_at DateTime
183+
prompt String?
184+
response String?
185+
checkpoint_id String?
174186
}
175187
```
176188

@@ -273,6 +285,7 @@ globalPlugins: [
273285
responseField: 'response',
274286
// optional
275287
// debugField: 'debug',
288+
checkpointIdField: 'checkpoint_id',
276289
},
277290
// optional, see the "Persistent checkpointer" section below
278291
// checkpointResource: { ... },
@@ -870,9 +883,9 @@ import type { AdminForthResourceInput } from 'adminforth';
870883

871884
export default {
872885
dataSource: 'maindb',
873-
table: 'checkpoints',
874-
resourceId: 'checkpoints',
875-
label: 'Checkpoints',
886+
table: 'agent_checkpoints',
887+
resourceId: 'agent_checkpoints',
888+
label: 'Agent Checkpoints',
876889
recordLabel: (record) => record.id,
877890
options: {
878891
allowedActions: {
@@ -895,7 +908,7 @@ export default {
895908
type: AdminForthDataTypes.STRING,
896909
},
897910
{
898-
name: 'checkpoint_ns',
911+
name: 'checkpoint_namespace',
899912
type: AdminForthDataTypes.STRING,
900913
},
901914
{
@@ -919,7 +932,7 @@ export default {
919932
type: AdminForthDataTypes.STRING,
920933
},
921934
{
922-
name: 'seq',
935+
name: 'sequence',
923936
type: AdminForthDataTypes.INTEGER,
924937
},
925938
{
@@ -962,26 +975,26 @@ export default {
962975
Add a matching table to your schema:
963976

964977
```prisma title='./schema.prisma'
965-
model checkpoints {
978+
model agent_checkpoints {
966979
id String @id
967980
thread_id String
968-
checkpoint_ns String
981+
checkpoint_namespace String
969982
checkpoint_id String
970983
parent_checkpoint_id String?
971984
row_kind String
972985
task_id String?
973-
seq Int
986+
sequence Int
974987
created_at DateTime
975988
checkpoint_payload String?
976989
metadata_payload String?
977990
writes_payload String?
978991
schema_version Int
979992
980-
@@index([thread_id, checkpoint_ns, checkpoint_id])
993+
@@index([thread_id, checkpoint_namespace, checkpoint_id])
981994
}
982995
```
983996

984-
The payload fields can be stored as strings. The plugin serializes and deserializes checkpoint JSON on its own. The composite index on `(thread_id, checkpoint_ns, checkpoint_id)` is recommended because the checkpointer filters rows by these columns.
997+
The payload fields can be stored as strings. The plugin serializes and deserializes checkpoint JSON on its own. The composite index on `(thread_id, checkpoint_namespace, checkpoint_id)` is recommended because the checkpointer filters rows by these columns.
985998

986999
Run migration:
9871000

@@ -1030,17 +1043,18 @@ new AdminForthAgent({
10301043
createdAtField: 'created_at',
10311044
promptField: 'prompt',
10321045
responseField: 'response',
1046+
checkpointIdField: 'checkpoint_id',
10331047
},
10341048
checkpointResource: {
1035-
resourceId: 'checkpoints',
1049+
resourceId: 'agent_checkpoints',
10361050
idField: 'id',
10371051
threadIdField: 'thread_id',
1038-
checkpointNamespaceField: 'checkpoint_ns',
1052+
checkpointNamespaceField: 'checkpoint_namespace',
10391053
checkpointIdField: 'checkpoint_id',
10401054
parentCheckpointIdField: 'parent_checkpoint_id',
10411055
rowKindField: 'row_kind',
10421056
taskIdField: 'task_id',
1043-
sequenceField: 'seq',
1057+
sequenceField: 'sequence',
10441058
createdAtField: 'created_at',
10451059
checkpointPayloadField: 'checkpoint_payload',
10461060
metadataPayloadField: 'metadata_payload',

0 commit comments

Comments
 (0)