From 5c0c6b3e428923e064cdb267dcf1b1c17818756a Mon Sep 17 00:00:00 2001 From: Mikhail Date: Sat, 29 Aug 2026 23:05:43 +0300 Subject: [PATCH] bound local cognitive household response budgets --- cmd/core-runtime/cognitive_interpretation.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cmd/core-runtime/cognitive_interpretation.go b/cmd/core-runtime/cognitive_interpretation.go index dc7bc48..10fb842 100644 --- a/cmd/core-runtime/cognitive_interpretation.go +++ b/cmd/core-runtime/cognitive_interpretation.go @@ -28,6 +28,15 @@ type cognitiveInterpretationClient struct { media *http.Client } +const ( + // Household interpretation and response review are intentionally compact + // calls. Keeping their output bounded prevents a loaded local model from + // spending the whole request budget generating unnecessary prose. + responseReviewMaxOutputBytes = 512 + stableKnowledgeMaxOutputBytes = 512 + semanticInterpretMaxOutputBytes = 1024 +) + // ReviewResponse asks the cognitive gateway to turn a locally assembled draft // into a natural answer. The draft remains the safe fallback when cognition is // unavailable; the model does not mutate canonical state or execute actions. @@ -47,7 +56,7 @@ func (c cognitiveInterpretationClient) ReviewResponse(ctx context.Context, sessi Version: cognitive.CreatorAdvisoryV1, RequestID: cognitive.RequestID(requestID), ActorID: session.ActorID, PrincipalID: session.PrincipalID, ScopeID: authority.ScopeID("domovoy-global-scope"), Message: prompt, - Context: context, Locale: "ru", MaxOutputBytes: 2048, DataPolicy: capability.DataPolicyLocalOnly, + Context: context, Locale: "ru", MaxOutputBytes: responseReviewMaxOutputBytes, DataPolicy: capability.DataPolicyLocalOnly, Meaning: cognitive.TaskMeaning{ SpeechAct: "RESPONSE_REVIEW", CapabilityHints: meaning.CapabilityHints, @@ -101,7 +110,7 @@ func (c cognitiveInterpretationClient) AnswerStableKnowledge(ctx context.Context payload, err := json.Marshal(cognitive.GatewayAdvisoryRequest{ Version: cognitive.CreatorAdvisoryV1, RequestID: cognitive.RequestID(requestID), ActorID: session.ActorID, PrincipalID: session.PrincipalID, ScopeID: authority.ScopeID("domovoy-global-scope"), - Message: prompt, Context: context, Locale: "ru", MaxOutputBytes: 1024, DataPolicy: capability.DataPolicyLocalOnly, + Message: prompt, Context: context, Locale: "ru", MaxOutputBytes: stableKnowledgeMaxOutputBytes, DataPolicy: capability.DataPolicyLocalOnly, Meaning: cognitive.TaskMeaning{SpeechAct: "STABLE_KNOWLEDGE_ANSWER", CapabilityHints: meaning.CapabilityHints, RequestedOutcome: meaning.RequestedOutcome, InformationRequestKind: meaning.InformationRequestKind, ConfidenceMillis: meaning.ConfidenceMillis}, }) if err != nil { @@ -294,7 +303,7 @@ func buildGatewayInterpretationRequest(session identity.CreatorSession, utteranc ScopeID: authority.ScopeID("domovoy-global-scope"), Message: utterance.Content, Locale: "ru", - MaxOutputBytes: 4096, + MaxOutputBytes: semanticInterpretMaxOutputBytes, DataPolicy: capability.DataPolicyLocalOnly, DeterministicSpeechAct: string(semantic.Interpretation.SpeechAct), DeterministicSecondary: string(semantic.Interpretation.SecondarySpeechAct),