> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ko/llms.txt # 마스트라.getAgentById() 그만큼`.getAgentById()`메소드는 등록된 Agent를 검색합니다.`id`. 먼저 등록된 Agent를 검색합니다.`agent.id`. 일치하는 Agent가 없으면 다음으로 대체됩니다.[`Mastra.getAgent()`](https://mastra.zisheng.pro/ko/reference/core/getAgent)제공된 값을 Agent 레지스트리 키로 처리합니다. 코드에 정의된 Agent를 가져오려면 `mastra.getAgentById(id)`를 사용합니다. 버전이 지정된 Agent를 가져오려면 `await mastra.getAgentById(id, version)`을 사용합니다. ## 사용예 다음 예에서는 Agent를 등록하고 ID로 검색한 후 반환된 Agent를 사용합니다. ```typescript import { Agent } from '@mastra/core/agent' import { Mastra } from '@mastra/core/mastra' const supportAgent = new Agent({ id: 'support-agent-id', name: 'Support Agent', instructions: 'Answer support questions clearly and concisely.', model: 'openai/gpt-5.6-sol', }) export const mastra = new Mastra({ agents: { supportAgent, }, }) const agent = mastra.getAgentById('support-agent-id') const response = await agent.generate('How can I reset my password?') ``` ## 매개변수 **id** (`string`): 가져올 Agent의 ID입니다. Mastra는 먼저 등록된 Agent에서 agent.id를 검색합니다. 일치하는 항목이 없으면 이 값을 Agent 레지스트리 키로 사용하여 getAgent()를 호출합니다. **version** (`{ versionId: string } | { status?: 'draft' | 'published' }`): 버전이 지정된 Agent를 가져오기 위한 선택적 버전 선택기입니다. 제공하면 메서드가 프로미스를 반환합니다. **version.versionId** (`string`): 가져올 특정 Agent 버전의 ID입니다. **version.status** (`'draft' | 'published'`): 이 게시 상태에 해당하는 최신 Agent 버전을 선택합니다. ## 보고 **agent** (`TAgents[TAgentName]`): version을 생략했을 때 지정된 ID에 해당하는 Agent 인스턴스입니다. **agent** (`Promise`): version을 제공했을 때 버전이 지정된 Agent 인스턴스로 해석되는 프로미스입니다. ID나 레지스트리 키로 Agent를 찾지 못하면 `MastraError`가 발생합니다. ## 관련된 - [마스트라.getAgent()](https://mastra.zisheng.pro/ko/reference/core/getAgent) - [Agent 개요](https://mastra.zisheng.pro/ko/docs/agents/overview)