MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / ExecuteOneRequest

Method ExecuteOneRequest

agent/subagent.go:133–327  ·  view source on GitHub ↗
(ctx context.Context, prompt string, sessionState *SubAgentSessionState)

Source from the content-addressed store, hash-verified

131
132func (s *SubAgent) ExecuteOneRequest(ctx context.Context, prompt string, sessionState *SubAgentSessionState) SubAgentRequestResult {
133 if sessionState == nil {
134 sessionState = s.createSessionState(ctx, prompt)
135 }
136 if sessionState.AbortCheck == nil {
137 sessionState.AbortCheck = func() bool { return false }
138 }
139 if sessionState.SurfacedMemoryIDs == nil {
140 sessionState.SurfacedMemoryIDs = map[string]struct{}{}
141 }
142 messages := sessionState.Messages
143 systemPrompt := sessionState.SystemPrompt
144 continuationRetries := 0
145 shouldDrainNotifications := true
146 fullText := ""
147
148 for turn := 0; turn < s.MaxTurns; turn++ {
149 if ctx.Err() != nil {
150 return s.contextStopResult(sessionState, fullText, ctx.Err())
151 }
152 if s.Aborted || sessionState.AbortCheck() {
153 return SubAgentRequestResult{
154 FinalText: "Sub-agent aborted by user.",
155 TotalInputTokens: sessionState.TotalInputTokens,
156 TotalOutputTokens: sessionState.TotalOutputTokens,
157 }
158 }
159 if shouldDrainNotifications {
160 s.drainPendingNotifications(sessionState)
161 }
162 shouldDrainNotifications = true
163
164 runtime := skills.CollectInlineSkillRuntime(messages)
165 activeRegistry := s.Registry
166 if runtime.HasAllowedTools {
167 allow := map[string]struct{}{}
168 for _, name := range runtime.AllowedToolNames {
169 allow[name] = struct{}{}
170 }
171 activeRegistry = s.Registry.FilteredCopy(allow, nil, false, false)
172 }
173 model := s.Model
174 if runtime.ModelOverride != nil && *runtime.ModelOverride != "" {
175 model = *runtime.ModelOverride
176 }
177 client, err := CreateConfiguredLLMClient(s.Config, model, s.Config.APIMaxTokens, s.ThinkingBudget, api.DefaultRetryConfigPtr())
178 if err != nil {
179 return SubAgentRequestResult{
180 FinalText: "Sub-agent API call failed: " + err.Error(),
181 TotalInputTokens: sessionState.TotalInputTokens,
182 TotalOutputTokens: sessionState.TotalOutputTokens,
183 }
184 }
185 toolSchemas := activeRegistry.GetAPISchemas()
186 var toolCalls []coretools.ToolCall
187 fullText = ""
188 var thinkingBlocks []map[string]any
189 currentMessageID := ""
190 outputTruncated := false

Calls 15

createSessionStateMethod · 0.95
contextStopResultMethod · 0.95
buildExecutionContextMethod · 0.95
CreateLLMClientFunction · 0.92
DefaultRetryConfigPtrFunction · 0.92
TruncateResultFunction · 0.85
FilteredCopyMethod · 0.80
GetAPISchemasMethod · 0.80