MCPcopy Create free account
hub / github.com/FastMAS/KVCOMM / _async_execute

Method _async_execute

KVCOMM/agents/code_writing.py:190–245  ·  view source on GitHub ↗

To be overriden by the descendant class

(self, input:Dict[str,str],  spatial_info:Dict[str,Any], temporal_info:Dict[str,Any], mode: str = "default", **kwargs)

Source from the content-addressed store, hash-verified

188 return response
189
190 async def _async_execute(self, input:Dict[str,str], spatial_info:Dict[str,Any], temporal_info:Dict[str,Any], mode: str = "default", **kwargs):
191 """ To be overriden by the descendant class """
192 """ Use the processed input to get the result """
193 """ The input type of this node is Dict """
194 if mode == "default":
195 self.internal_tests = self.extract_example(input)
196 request_uid = input.get("_request_uid")
197 inputs = await self._process_inputs(
198 input,
199 spatial_info,
200 temporal_info,
201 mode=mode,
202 **kwargs,
203 )
204 system_prompt = inputs["system_prompt"]
205 user_prompt = inputs["user_prompt"]
206 if system_prompt == "is_solved":
207 return GenerationResult(
208 text=user_prompt,
209 mode="default",
210 ttft=0.0,
211 )
212 message = [{'role':'system','content':system_prompt},{'role':'user','content':user_prompt}]
213 result = await self.llm.agen(
214 message,
215 request_uid=request_uid,
216 agent_id=self.id,
217 agent_name=self.agent_name,
218 agent_role=self.role,
219 )
220 return result
221
222 assert mode == "allow_kv_reuse", f"Unsupported async execution mode: {mode}"
223 request_uid = input.get("_request_uid") or kwargs.get("request_uid")
224 if request_uid is None:
225 raise ValueError("request_uid is required for request-scoped anchor updates.")
226 self.internal_tests = self.extract_example(input)
227
228 mode_data = await self._process_inputs(
229 input,
230 spatial_info,
231 temporal_info,
232 mode=mode,
233 **kwargs,
234 )
235 preferred_mode = mode_data["preferred_mode"]
236 result = await self.llm.generate_for_agent(
237 request_uid=request_uid,
238 message=input['task'],
239 preferred_mode=preferred_mode,
240 output_dir=kwargs.get("output_dir"),
241 agent_id=self.id,
242 agent_name=self.agent_name,
243 agent_role=self.role,
244 )
245 return input['task'], result

Callers

nothing calls this directly

Calls 6

extract_exampleMethod · 0.95
_process_inputsMethod · 0.95
GenerationResultClass · 0.90
generate_for_agentMethod · 0.80
getMethod · 0.45
agenMethod · 0.45

Tested by

no test coverage detected