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

Method _async_execute

KVCOMM/agents/copy_machine.py:137–185  ·  view source on GitHub ↗

Handle asynchronous execution across different KV cache modes.

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

Source from the content-addressed store, hash-verified

135 return response
136
137 async def _async_execute(self, input:Dict[str,str], spatial_info:Dict[str,Dict], temporal_info:Dict[str,Dict], mode: str = "default", **kwargs):
138 """Handle asynchronous execution across different KV cache modes."""
139 if mode == "default":
140 request_uid = input.get("_request_uid")
141 inputs = await self._process_inputs(
142 input,
143 spatial_info,
144 temporal_info,
145 mode=mode,
146 **kwargs,
147 )
148 system_prompt = inputs["system_prompt"]
149 user_prompt = inputs["user_prompt"]
150 message = [{'role':'system','content':system_prompt},{'role':'user','content':user_prompt}]
151 result = await self.llm.agen(
152 message,
153 max_tokens=self.llm.DEFAULT_MAX_TOKENS,
154 request_uid=request_uid,
155 agent_id=self.id,
156 agent_name=self.agent_name,
157 agent_role=self.role,
158 )
159 return result
160
161 assert mode == "allow_kv_reuse", f"Unsupported async execution mode: {mode}"
162 request_uid = input.get("_request_uid") or kwargs.get("request_uid")
163 if request_uid is None:
164 raise ValueError("request_uid is required for request-scoped anchor updates.")
165
166 mode_data = await self._process_inputs(
167 input,
168 spatial_info,
169 temporal_info,
170 mode=mode,
171 **kwargs,
172 )
173 preferred_mode = mode_data["preferred_mode"]
174 result = await self.llm.generate_for_agent(
175 request_uid=request_uid,
176 message=input['task'],
177 preferred_mode=preferred_mode,
178 output_dir=kwargs.get("output_dir"),
179 agent_id=self.id,
180 agent_name=self.agent_name,
181 agent_role=self.role,
182 test_time=True,
183 max_tokens=OUT_LENGTH
184 )
185 return input['task'], result

Callers

nothing calls this directly

Calls 4

_process_inputsMethod · 0.95
generate_for_agentMethod · 0.80
getMethod · 0.45
agenMethod · 0.45

Tested by

no test coverage detected