order5.txt•7.04 kB
> https://github.com/a2aproject/a2a-samples/tree/main/samples/python/agents/langgraph 이 자료를 확인해보는 것이 좋아. 결국 LangGraph 에서 어떻게 A2A 서버로
넘어갔는지를 확인할 수 있는 코드들이 들어있거든. 내부에 app 이라고 들어가보면 될 것 같아.
⏺ 좋은 자료를 알려주셨네요! LangGraph를 A2A 서버로 구현한 실제 예제를 확인해보겠습니다.
⏺ Fetch(https://github.com/a2aproject/a2a-samples/tree/main/samples/python/agents/langgraph)
⎿ Received 241.3KB (200 OK)
⏺ app 디렉토리의 실제 코드를 확인해보겠습니다.
⏺ Fetch(https://github.com/a2aproject/a2a-samples/tree/main/samples/python/agents/langgraph/app)
⎿ Received 177KB (200 OK)
⏺ 주요 파일들의 실제 코드를 확인해보겠습니다.
⏺ Fetch(https://raw.githubusercontent.com/a2aproject/a2a-samples/main/samples/python/agents/langgraph/app/__main__.py)
⎿ Received 3KB (200 OK)
⏺ 이제 agent_executor.py를 확인해보겠습니다. 이 파일에 LangGraph 통합이 어떻게 되어있는지 볼 수 있을 것 같습니다.
⏺ Fetch(https://raw.githubusercontent.com/a2aproject/a2a-samples/main/samples/python/agents/langgraph/app/agent_executor.py)
⎿ Received 2.9KB (200 OK)
⏺ 이제 agent.py를 확인해서 실제 LangGraph 에이전트가 어떻게 구현되어 있는지 보겠습니다.
⏺ Fetch(https://raw.githubusercontent.com/a2aproject/a2a-samples/main/samples/python/agents/langgraph/app/agent.py)
⎿ Received 5.6KB (200 OK)
⏺ 이제 이 예제를 참고해서 우리 프로젝트의 A2A 서버들을 수정해보겠습니다. 주요 발견사항:
1. A2AStarletteApplication을 사용해서 서버를 구성
2. DefaultRequestHandler로 요청 처리
3. InMemoryTaskStore와 InMemoryPushNotifier 사용
4. LangGraph 에이전트를 실행하는 별도의 AgentExecutor 클래스 구현
우리 프로젝트의 A2A 서버를 이 패턴에 맞게 수정해보겠습니다.
⏺ Update Todos
⎿ ☐ A2A 서버 구조 개선 - a2a-samples 예제 참고
☐ planning_a2a_server.py 수정
☐ research_a2a_server.py 수정
☐ report_writing_a2a_server.py 수정
☐ Docker 재실행 및 테스트
⏺ 먼저 planning_a2a_server.py를 수정해보겠습니다.
⏺ Read(../agents/a2a_servers/planning_a2a_server.py)
⎿ Read 441 lines (ctrl+r to expand)
⏺ 보니까 우리 프로젝트의 A2A 서버들은 이미 a2a-samples 예제와 비슷한 패턴으로 구현되어 있네요. 하지만 "Queue is closed" 오류가 발생하는 이유를 찾아보겠습니다.
a2a 패키지의 버전이나 사용법이 문제일 수 있습니다. 예제에서는 InMemoryPushNotifier도 사용하고 있는데, 우리 코드에는 없습니다. 이를 추가해보겠습니다.
⏺ Update(../agents/a2a_servers/planning_a2a_server.py)
⎿ Updated ../agents/a2a_servers/planning_a2a_server.py with 2 additions
10 from a2a.server.tasks.inmemory_task_store import InMemoryTaskStore
11 from a2a.server.tasks.task_updater import TaskUpdater
12 from a2a.server.apps.jsonrpc.starlette_app import A2AStarletteApplication
13 + from a2a.server.notifiers.inmemory_push_notifier import InMemoryPushNotifier
14 + import httpx
15 from a2a.types import (
16 AgentCard,
17 AgentSkill,
⏺ Update(../agents/a2a_servers/planning_a2a_server.py)
⎿ Updated ../agents/a2a_servers/planning_a2a_server.py with 8 additions and 1 removal
422 # Task Store 생성
423 task_store = InMemoryTaskStore()
424
425 + # HTTP Client 생성
426 + httpx_client = httpx.AsyncClient()
427 +
428 + # Push Notifier 생성
429 + push_notifier = InMemoryPushNotifier(httpx_client)
430 +
431 # Request Handler 생성
432 request_handler = DefaultRequestHandler(
433 agent_executor=PlanningAgentExecutor(),
434 - task_store=task_store
434 + task_store=task_store,
435 + push_notifier=push_notifier
436 )
437
438 # A2A Server 생성
⏺ Update Todos
⎿ ☒ planning_a2a_server.py 수정
☐ A2A 서버 구조 개선 - a2a-samples 예제 참고
☐ research_a2a_server.py 수정
☐ report_writing_a2a_server.py 수정
☐ Docker 재실행 및 테스트
⏺ 이제 research_a2a_server.py도 동일하게 수정하겠습니다.
⏺ Read(../agents/a2a_servers/research_a2a_server.py)
⎿ Read 50 lines (ctrl+r to expand)
⏺ Search(pattern: "task_store = InMemoryTaskStore", path: "../agents/a2a_servers/research_a2a_server.py")
⎿ Found 1 file (ctrl+r to expand)
⏺ Read(../agents/a2a_servers/research_a2a_server.py)
⎿ Read 50 lines (ctrl+r to expand)
⏺ Update(../agents/a2a_servers/research_a2a_server.py)
⎿ Updated ../agents/a2a_servers/research_a2a_server.py with 2 additions
10 from a2a.server.tasks.inmemory_task_store import InMemoryTaskStore
11 from a2a.server.tasks.task_updater import TaskUpdater
12 from a2a.server.apps.jsonrpc.starlette_app import A2AStarletteApplication
13 + from a2a.server.notifiers.inmemory_push_notifier import InMemoryPushNotifier
14 + import httpx
15 from a2a.types import (
16 AgentCard,
17 AgentSkill,
⏺ Update(../agents/a2a_servers/research_a2a_server.py)
⎿ Updated ../agents/a2a_servers/research_a2a_server.py with 8 additions and 1 removal
432 # Task Store 생성
433 task_store = InMemoryTaskStore()
434
435 + # HTTP Client 생성
436 + httpx_client = httpx.AsyncClient()
437 +
438 + # Push Notifier 생성
439 + push_notifier = InMemoryPushNotifier(httpx_client)
440 +
441 # Request Handler 생성
442 request_handler = DefaultRequestHandler(
443 agent_executor=ResearchAgentExecutor(),
444 - task_store=task_store
444 + task_store=task_store,
445 + push_notifier=push_notifier
446 )
447
448 # A2A Server 생성
⏺ Update Todos
⎿ ☒ planning_a2a_server.py 수정
☒ research_a2a_server.py 수정
☐ A2A 서버 구조 개선 - a2a-samples 예제 참고
☐ report_writing_a2a_server.py 수정
☐ Docker 재실행 및 테스트
⏺ 이제 report_writing_a2a_server.py도 수정하겠습니다.
⏺ Read(../agents/a2a_servers/report_writing_a2a_server.py)
⎿ Read 50 lines (ctrl+r to expand)
⏺ Search(pattern: "task_store = InMemoryTaskStore", path: "../agents/a2a_servers/report_writing_a2a_server.py")
⎿ Found 1 file (ctrl+r to expand)