sessionctx

package
v1.0.0-alpha.36 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package sessionctx threads the current chat session id through the per-call context.Context so tool callbacks can access it without the framework having to pass it explicitly through every layer.

Sessions are per-chat-turn, not per-process — the runtime hosts many sessions over its lifetime — so env vars are the wrong channel. Putting the value on ctx mirrors how cancellation, deadlines, and tracing IDs already flow.

Producers: pkg/agent/service.go's ChatStream wraps the ctx before invoking the model loop. Consumers: tool callbacks pull the session id when they want to stamp it onto outbound work (e.g. job_submit attaches it as the io.openotters.session-id label so /jobs filtering by session works).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func From

func From(ctx context.Context) string

From returns the session id attached by With, or "" when the ctx carries none. Tool callbacks treat "" as "no session is in scope" — they should NOT fall back to env vars or the agent's own id; absence is meaningful.

func With

func With(ctx context.Context, sessionID string) context.Context

With returns a derived ctx carrying sessionID. Empty input is a no-op (returns the parent ctx) — keeps producer call sites from having to guard.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL