mirror of
https://github.com/esengine/DeepSeek-Reasonix.git
synced 2026-11-07 10:45:59 -10:00
internal/ was 141 packages side by side, so nothing but a reader's memory
said which were foundations and which assembled the rest. Each now sits in a
layer directory, and the directory is the declaration:
base L0 foundation with no domain in it
contract L1 types and interfaces the layers above agree on
model, tools, safety, ext, state, platform
L2 subsystems, peers of one another
runtime L3 the turn engine
session L4 the controller
assembly L5 the composition root
frontend L6 cli, serve, acp and the host adapters
Only paths change: package names, code and behaviour do not. Imports,
repolint and coverage baselines, sensitive paths, CI package lists and docs
follow the new paths; release notes keep the paths they were written with,
and sample paths inside tests and fixtures keep theirs.
repolint gains layer-order: a package may import its own layer and those
below it, read from where it lives. The 47 imports that point upward today
are recorded as that rule's opening debt (-allow-widen, a new rule's first
baseline) and can only go down. Most of it is config, which still reaches
into eight subsystems and is the next thing to take apart; the rest is
event, history and a few tools reaching into runtime for types that belong
in contract.
51 lines
1.8 KiB
Go
51 lines
1.8 KiB
Go
package agent
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
"reasonix/internal/contract/provider"
|
|
)
|
|
|
|
// responseFormatContextKey carries a per-turn structured-output request
|
|
// through Run's context (same pattern as runStepLimitContextKey). The agent
|
|
// reads it when building the provider.Request so a turn can ask for
|
|
// json_object output without changing the agent's persistent state.
|
|
type responseFormatContextKey struct{}
|
|
|
|
// WithResponseFormat attaches a structured-output format to a turn context.
|
|
// Empty format is a no-op returning ctx unchanged (byte-stable default path).
|
|
func WithResponseFormat(ctx context.Context, format string) context.Context {
|
|
if strings.TrimSpace(format) == "" {
|
|
return ctx
|
|
}
|
|
return context.WithValue(ctx, responseFormatContextKey{}, strings.TrimSpace(format))
|
|
}
|
|
|
|
// responseFormatFromContext returns the turn-scoped structured-output format
|
|
// (e.g. "json_object") or "" when none was requested.
|
|
func responseFormatFromContext(ctx context.Context) string {
|
|
if ctx == nil {
|
|
return ""
|
|
}
|
|
f, _ := ctx.Value(responseFormatContextKey{}).(string)
|
|
return f
|
|
}
|
|
|
|
// ResponseFormatFromRequest is the exported form of responseFormatFromRequest:
|
|
// control tests assert the turn-bound format actually reaches the agent
|
|
// request path (review #7234 — format bound to turn, not global slot).
|
|
func ResponseFormatFromRequest(ctx context.Context) *provider.ResponseFormat {
|
|
return responseFormatFromRequest(ctx)
|
|
}
|
|
|
|
// responseFormatFromRequest returns the turn-scoped structured-output format
|
|
// (e.g. "json_object") as a Request field, or nil when none was requested
|
|
// (nil keeps the wire byte-stable for prompt caching).
|
|
func responseFormatFromRequest(ctx context.Context) *provider.ResponseFormat {
|
|
if f := responseFormatFromContext(ctx); f != "" {
|
|
return &provider.ResponseFormat{Type: f}
|
|
}
|
|
return nil
|
|
}
|