-
Notifications
You must be signed in to change notification settings - Fork 1
Sessions
theirish81 edited this page Jul 30, 2026
·
3 revisions
Session are isolated contexts and are task-oriented.
Session output is bound to one of more schema objects using the x-session attribute.
A session must contain:
- prompt
string: a prompt defining the objective of the session.
A session may contain:
- prePrompt
string|[]string: one or more prompts to be executed before the main prompt. This prompt only enriches the session context but does not produce effects on the output. PrePrompts are the only prompts allowed to invoke tools. - timeout
string: the maximum amount of time the session can run before it is terminated (Go duration format). - attempts
int: the maximum number of attempts the session can be executed before it is terminated. - context:
bool: whether the partial result should be injected in the session as context. - tools:
array<tool definition>: a list of tools that are allowed in this session. - iterateOn:
string: Go Expr expression resolving to a list of values to iterate on. The session will execute as many times as the length of the list. - vars
map<string, any>: a map of variables that are local to the session. - preCalls
array<call definition>: a list of function calls to execute before the prompts. - resources
array<resource definition>: a list of resources to be used by the session. See: Resources.
NOTE: all prompts can be templetized* using Go Templates.
In this simple example, the session s1 will be executed and the output will be bound to the schema item that was
marked with x-session: s1.
sessions:
s1:
prompt: "what's the meaning of life?"
schema:
type: object
required: ["answer"]
properties:
answer:
x-session: s1
description: "the answer to the question
type: string
Same example, but in code:
sm := frags.NewSessionManager()
sm.Sessions = frags.Sessions {
"s1": frags.Session {
Prompt: "what is the meaning of life?",
},
}
session := "s1"
sm.Schema = &frags.Schema{
Type: "object",
Required: []string{"answer"},
Properties: map[string]*frags.Schema{
"answer": &frags.Schema{
XSession: &session,
Description: "the answer to the question",
Type: "string",
},
},
}