You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After installing the RemoteA2aAgent as a subagent on the Supervisor, sending a request to the RemoteA2aAgent during the test, the agent has even checked the operation.
RemoteA2aAgent then responds, but 400 BadRequest errors are continuously occurring on the Supervisor side.
How can I solve this issue
Executor function of RemoteA2aAgent.
importjsonclassReviewAgentExecutor(A2aAgentExecutor)
def__init__(self) ->None:
self.agent=Noneself.runner=Noneself._current_session=Noneself._session_mapping=Dict[str,str] = {}
def_init_agent(self) ->None:
ifself.agentisNone:
self.agent=sequential_agentself.runner=Runner(
app_name="ReviewAgent",
agent=sequential_agent,
artifact_service=GcsArtifactService(bucket_name=""),
session_service=VertexAiSessionService(project="",location='',agent_engine_id=''),
memory_service=VertexAiMemoryBankService(project="",location='')
)
asyncdefexecute(self, context: RequestContext,event_queue:EventQueue) ->None:
ifself.agentisNone:
self._init_agent()
updater=TaskUpdater(event_queue,context.task_id,context.context_id)
ifnotcontext.current_task:
awaitupdater.submit()
awaitupdater.start_work()
try:
session=awaitself._get_or_create_session(context)
self._current_session=sessioncategory=context.metadata.get("category")
part_nm=context.metadata.get('part_nm')
designer=context.metadata.get("designer")
chat_id=context.metadata.get("chatId")
date=context.metadata.get('date')
base_instruction=f""" 작업 환경 정보 Chat ID : {chat_id} Part NM : {part_nm} Designer : {designer} Date : {date} """ifcategory=="L0 신규 개발":
source_gcs_path=context.metadata.get('source_gcs_path')
argumented_query=f"{base_instruction}[작업유형] : 신규 개발, 원천 경로 {source_gcs_path}"ifcategory=="L0 변경 개발":
chg_req_path=context.metadata.get('chg_req_path')
argumented_query=f"{base_instruction}[작업유형] : 변경 개발, 변경 요청서 경로 {chg_req_path}"user_query=context.get_user_input()
final_prompt=f"{argumented_query}\n{user_query}"content=types.Content(role='user',parts= [types.Part(text=final_prompt)])
asyncforeventinself.runner.run_async(
session_id=session.id,
user_id=context.metadata.get('chat_id'),
new_message=content,
):
ifevent.contentandevent.content.parts:
forpartinevent.content.parts:
fn_resp=getattr(part,'function_response',None)
iffn_resp=='function_response':
fn_name=fn_resp.namefn_result=fn_resp.responseiffn_name=="tool_run_rag_tool":
session.state["ReviewToolResult"] =fn_resultiffn_name=="tool_run_change_tool":
session.state["ReviewToolResult"] =fn_resultrefreshed_session=awaitself.runner.session_service.get_session(
app_name=self.runner.app_name,
user_id=context.metadata.get('chat_id'),
session_id=session.id)
state=refreshed_session.statereview_data=state.get('review_result')
verify_data=state.get('verification_result')
awaitevent_queue.enqueue_event(
TaskStatusUpdateEvent(
task_id=context.task_id,
status=TaskTatus(
state=TaskState.working,
timmestamp=datetime.now(),
message=Message(
message_id=str(uuid.uuid4()),
role=Role.agent,
parts= [
Part(root=TextPart(
kind='text',
metadata==None,
text=json.dumps(review_data,ensure_ascii=False))),
Part(root=TextPart(
kind='text',
metadata==None,
text=json.dumps(verify_data,ensure_ascii=False))),
Part(root=TextPart(
kind='text',
metadata==None,
text=json.dumps(session.id,ensure_ascii=False),
))]
)
),
contetxt_id=context.context_id,
final=True
)
)
exceptExceptionase:
awaitupdater.update_status(
TaskState.failed, message=new_agent_text_message(f"Error: {e!s}")
)
raiseasyncdef_get_or_create_session(self,context:str):
"""Get existing session or create new one"""incoming_session_id=Noneifcontext.metadata:
incoming_session_id=context.metadata.get('vertex_session_id')
session=Noneifincoming_session_id:
try:
session=awaitself.runner.session_service.get_session(
app_name=self.runner.app_name,
user_id=context.metadata.get('chat_id'),
session_id=incoming_session_id
)
exceptException:
session=Noneifnotsession:
session=awaitself.runner.session_service.create_session(
app_name=self.runner.app_name,
user_id=context.metadata.get('chat_id'),
)
returnsessiondef_extract_answer(self,event) ->str:
ifnothasattr(event,'content') orevent.contentisNone:
return"No content in event"ifnothasattr(event.content,'parts') orevent.content.partsisNone:
return"No parts in content"parts=event.content.partstext_parts= [part.textforpartinpartsifhasattr(part,'text') andpart.text]
return" ".join(text_parts) iftext_partselse"No Answer Found"asyncdefcancel(self,context:RequestContext,event_queue: EventQueue)->NoReturn :
raiseServerError(error=UnsupportedOperationError())
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
After installing the RemoteA2aAgent as a subagent on the Supervisor, sending a request to the RemoteA2aAgent during the test, the agent has even checked the operation.
RemoteA2aAgent then responds, but 400 BadRequest errors are continuously occurring on the Supervisor side.
How can I solve this issue
Executor function of RemoteA2aAgent.
plz helpme
Beta Was this translation helpful? Give feedback.
All reactions