Documentation
¶
Index ¶
- Constants
- func BindSessionCallTarget(ctx context.Context, targetSessionID string) (context.Context, error)
- func ChannelFromContext(ctx context.Context) (string, bool)
- func EnterSessionCall(ctx context.Context, sourceSessionID, targetSessionID string) (context.Context, error)
- func ExcludedToolsFromContext(ctx context.Context) []string
- func SystemOverrideFromContext(ctx context.Context) (string, bool)
- func TurnIDFromContext(ctx context.Context) string
- func WithChannel(ctx context.Context, channel string) context.Context
- func WithChatBinding(ctx context.Context, binding ChatBinding) context.Context
- func WithExcludedTools(ctx context.Context, names ...string) context.Context
- func WithSessionCallBudget(ctx context.Context) context.Context
- func WithSystemOverride(ctx context.Context, system string) context.Context
- func WithTurnID(ctx context.Context, turnID string) context.Context
- func WithoutChatBinding(ctx context.Context) context.Context
- type ChatBinding
- type SessionCall
Constants ¶
const MaxCallDepth = 4
MaxCallDepth bounds synchronous Session/delegate nesting. Raise it only when real workflows need deeper collaboration and root turn budgets still bound the resulting fan-out safely.
const MaxTotalSessionCalls = 16
MaxTotalSessionCalls bounds sibling fan-out across one root turn. Raise it only when measured workflows need more focused calls and the root timeout remains a sufficient aggregate cost bound.
Variables ¶
This section is empty.
Functions ¶
func BindSessionCallTarget ¶
BindSessionCallTarget adds a target resolved after call entry (session.create). Binding the current tail is idempotent for known-target send paths.
func ChannelFromContext ¶
ChannelFromContext returns the current chat channel when present.
func EnterSessionCall ¶
func EnterSessionCall(ctx context.Context, sourceSessionID, targetSessionID string) (context.Context, error)
EnterSessionCall increments nesting and optionally appends a known target. sourceSessionID seeds a top-level chain; inherited chains already contain it.
func ExcludedToolsFromContext ¶
ExcludedToolsFromContext returns the per-run excluded tool names when present.
func SystemOverrideFromContext ¶
SystemOverrideFromContext returns the per-run system prompt override when present.
func TurnIDFromContext ¶
TurnIDFromContext returns the current turn's identifier, or "" outside a turn.
func WithChannel ¶
WithChannel returns a child context that carries the current chat channel.
func WithChatBinding ¶
func WithChatBinding(ctx context.Context, binding ChatBinding) context.Context
WithChatBinding returns a child context carrying the durable chat binding this turn entered through.
func WithExcludedTools ¶
WithExcludedTools returns a child context that hides the named tools for a single run.
func WithSessionCallBudget ¶
WithSessionCallBudget allocates the shared call counter at a root runtime turn. Nested turns retain the same pointer through context inheritance.
func WithSystemOverride ¶
WithSystemOverride returns a child context that carries a per-run system prompt override.
func WithTurnID ¶
WithTurnID returns a child context carrying an identifier unique to one chat turn. The runtime mints it once per Chat call; consumers use it only to tell two turns apart, never to order them.
func WithoutChatBinding ¶
WithoutChatBinding returns a child context with no chat binding, whatever the parent carried.
A delegate (or any other nested run) inherits its parent's context, and the parent may be a Telegram or group turn. The binding is the authority to rotate and compact THAT chat's session, so inheriting it would let a delegate — whose own turn nobody is watching and whose task text can come from a tool result — reset the conversation that spawned it.
Types ¶
type ChatBinding ¶
type ChatBinding struct {
// Main marks a DM pinned to its user's singleton main session. Every other
// chat (group, private channel) resolves through the channel binding below.
Main bool
// Channel is the durable session channel of a non-main chat binding.
Channel string
// SessionKey is the chat's derived key, kept for legacy key-as-id lookups.
SessionKey string
}
ChatBinding describes the durable channel binding a chat turn entered through. Only the chat channel adapters attach it, so its absence is the signal that a turn is not channel-backed: Web/API sends, webhooks, and scheduler/task/delegate runs all leave it unset and therefore fail closed in consumers that require a durable chat.
It exists because a session row cannot answer the question. The Web UI can open the very same main session a DM is pinned to (`POST /sessions` with kind=main), and `ctx_conversation.channel` records whichever surface created the row first, so neither the session id nor its channel distinguishes a Telegram turn from a browser tab on the same session. The entry adapter does know, and this is how it says so.
func ChatBindingFromContext ¶
func ChatBindingFromContext(ctx context.Context) (ChatBinding, bool)
ChatBindingFromContext returns the durable chat binding of the current turn. The bool is false for any turn that did not enter through a chat channel.
type SessionCall ¶
SessionCall is the live synchronous Session-call chain. It is deliberately context-only: the caller and every child die together, so persistence would create replay risk rather than durability.
func SessionCallFromContext ¶
func SessionCallFromContext(ctx context.Context) (SessionCall, bool)
SessionCallFromContext returns a defensive copy of the active call chain.