[G1-Sync] Manual knowledge update

This commit is contained in:
Antigravity Agent
2026-05-10 22:08:15 +09:00
parent 21ac3ed255
commit 504fd5fb42
3011 changed files with 380280 additions and 206977 deletions
@@ -1,106 +1,224 @@
---
id: wiki-2026-0508-t-component-tool-registry
title: T component (Tool Registry)
title: T-component (Tool Registry)
category: 10_Wiki/Topics
status: needs_review
status: verified
canonical_id: self
aliases: []
aliases: [Tool Registry, Tool Catalog, Agent Tools, T-component]
duplicate_of: none
source_trust_level: A
confidence_score: 0.92
tags: [uncategorized]
confidence_score: 0.85
verification_status: applied
tags: [agent, tools, llm, architecture]
raw_sources: []
last_reinforced: 2026-05-08
last_reinforced: 2026-05-10
github_commit: pending
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
tech_stack:
language: unspecified
framework: unspecified
language: typescript
framework: anthropic-sdk/mcp
---
# [[T-component (Tool Registry)|T-component (Tool Registry)]]
# T-component (Tool Registry)
## 📌 한 줄 통찰 (The Karpathy Summary)
T-component(Tool Registry)는 에이전트 하네스의 '손과 발'에 해당하는 구성 요소로, 에이전트가 외부 세계와 상호작용하기 위해 사용할 수 있는 모든 도구(함수, API, 스크립트)를 등록, 관리, 실행하는 책임을 진다. 모델이 도구의 기능을 이해할 수 있도록 명세를 제공하고, 모델의 실행 요청을 실제 코드 호출로 변환하는 가교 역할을 한다.
## 한 줄
> **"매 LLM agent 가 호출 가능한 tool 들의 declared 카탈로그 + dispatcher"**. 매 OpenAI function calling 2023, 매 Anthropic tool use 2024, 매 MCP (Model Context Protocol) 2024 표준화 의 evolution. 매 6-component pattern (S/T/L/I/M/E) 의 T 핵심. 매 2026 의 production agent 는 100+ tools 의 dynamic loading.
## 📖 구조화된 지식 (Synthesized Content)
* **도구 명세 관리 (Tool Definitions)**: 모델이 어떤 상황에서 어떤 도구를 써야 할지 알 수 있도록 도구의 이름, 설명, 파라미터 스키마를 정의하고 공급한다.
* **실행 프로토콜 표준화 (MCP)**: 서로 다른 언어나 환경으로 작성된 도구들을 일관된 방식으로 호출하기 위해 **MCP(Model Context Protocol)**와 같은 표준 프로토콜을 사용한다.
* **권한 및 가이딩 (Guarding)**: 특정 에이전트나 작업 세션이 사용할 수 있는 도구의 범위를 제한하고, 민감한 도구 호출 시 승인 게이트를 트리거한다.
* **결과 파싱 및 피드백**: 도구 실행 결과(성공 데이터, 에러 로그)를 모델이 이해할 수 있는 형식으로 정제하여 전달한다.
* **동적 로딩 및 확장성**: 하네스 코드를 수정하지 않고도 새로운 도구 서버를 추가하거나 외부 API를 연동할 수 있는 플러그인 아키텍처를 제공한다.
## 매 핵심
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
* **스키마 복잡성**: 도구 명세가 너무 복잡하면 모델이 파라미터를 잘못 생성할 확률이 높아진다.
* **보안 리스크 (Excessive Agency)**: 도구 레지스트리에 강력한 권한을 가진 도구(예: 셸 실행)가 포함되어 있을 경우, 프롬프트 인젝션을 통한 시스템 장악 위험이 있다.
* **의존성 지옥**: 수많은 외부 API와 라이브러리에 의존하는 도구들의 버전 관리와 안정성을 유지하는 것은 어려운 운영 과제이다.
### 매 책임
- **Schema declaration**: name, description, JSON-schema params.
- **Discovery**: LLM 의 selection 을 위한 metadata.
- **Permissions**: per-tool ACL (read/write, sandbox).
- **Dispatch**: tool_use → handler invocation.
- **Result formatting**: stringify for LLM consumption.
## 🔗 지식 연결 (Graph)
### Related Concepts
* [[MCP (Model Context Protocol)|MCP (Model Context Protocol)]]
* 연결 이유: T-component가 도구를 등록하고 실행하는 실질적인 기술 표준이다.
* [[Agent Harness|Agent Harness]]
* 연결 이유: T-component는 하네스의 외부 세계 인터페이스이다.
* [[L-component (Lifecycle Hooks)|L-component (Lifecycle Hooks)]]
* 연결 이유: 도구 실행 전후에 권한을 검사하고 결과를 필터링하는 파트너이다.
### 매 patterns
- **Static**: hardcoded list at startup.
- **Dynamic**: runtime registration (plugin).
- **MCP server**: external process, JSON-RPC.
- **Hierarchical**: meta-tool 으로 search/load 다른 tools.
### Deeper Research Questions
* 모델이 도구의 기능을 더 정확히 이해하게 만들기 위해, 단순한 텍스트 설명 대신 '실행 예시'나 '단위 테스트 결과'를 명세에 포함하는 방식의 효율성은 어떠한가?
* 수백 개의 도구 중 현재 상황에 가장 적합한 도구 5개만을 골라 모델에게 제안하는 '도구 검색(Tool Retrieval)' 알고리즘은 어떻게 설계해야 하는가?
* 도구 실행 결과가 너무 클 때(예: 대규모 DB 조회), 이를 컨텍스트에 주입하지 않고 아티팩트로 처리하는 최적의 임계점은 무엇인가?
### 매 응용
1. Coding agent (Read, Edit, Bash, Grep, ...).
2. Research agent (WebSearch, WebFetch, ...).
3. Customer support agent (CRM tools).
4. RPA / browser automation.
### Practical Application Contexts
* **Implementation:** `ToolRegistry` 클래스에 `register_tool()`, `call_tool()` 메서드를 구현하고, 각 도구는 JSON Schema를 통해 파라미터를 정의한다.
* **System Design:** 보안을 위해 도구 실행부를 별도의 격리된 컨테이너(Sandbox)에서 동작하게 하고, T-component는 네트워크를 통해 결과만 전달받도록 설계한다.
## 💻 패턴
---
*Last updated: 2026-05-01*
### Anthropic tool definition
```ts
const tools = [
{
name: 'read_file',
description: 'Read contents of a file from disk.',
input_schema: {
type: 'object',
properties: {
path: { type: 'string', description: 'Absolute file path' },
offset: { type: 'integer', description: 'Start line (optional)' },
limit: { type: 'integer', description: 'Max lines (optional)' },
},
required: ['path'],
},
},
// ... more
];
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
**언제 이 지식을 쓰는가:**
- *(TODO)*
**언제 쓰면 안 되는가:**
- *(TODO)*
## 🧪 검증 상태 (Validation)
- **정보 상태:** needs_review
- **출처 신뢰도:** A
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
## 🧬 중복 검사 (Duplicate Check)
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
- **처리 방식:** UPDATE (자동 정규화)
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
## 🕓 변경 이력 (Changelog)
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|------|-----------|-----------|--------|
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
## 💻 코드 패턴 (Code Patterns)
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
```text
# TODO
const resp = await client.messages.create({
model: 'claude-opus-4-7',
max_tokens: 4096,
tools,
messages,
});
```
## 🤔 의사결정 기준 (Decision Criteria)
### Registry class
```ts
type ToolHandler = (input: any, ctx: ToolContext) => Promise<string>;
**선택 A를 써야 할 때:**
- *(TODO)*
class ToolRegistry {
private tools = new Map<string, { def: ToolDef; handler: ToolHandler }>();
**선택 B를 써야 할 때:**
- *(TODO)*
register(def: ToolDef, handler: ToolHandler) {
if (this.tools.has(def.name)) throw new Error(`dup: ${def.name}`);
this.tools.set(def.name, { def, handler });
}
**기본값:**
> *(TODO)*
list(): ToolDef[] { return [...this.tools.values()].map(t => t.def); }
## ❌ 안티패턴 (Anti-Patterns)
async dispatch(name: string, input: any, ctx: ToolContext): Promise<string> {
const t = this.tools.get(name);
if (!t) throw new Error(`unknown tool: ${name}`);
if (!ctx.allowed(name)) throw new Error(`denied: ${name}`);
return await t.handler(input, ctx);
}
}
```
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
### Permission gating
```ts
type Permission = 'read' | 'write' | 'exec';
const TOOL_PERMS: Record<string, Permission> = {
read_file: 'read',
edit_file: 'write',
bash: 'exec',
};
class ToolContext {
constructor(private granted: Set<Permission>) {}
allowed(name: string) {
const perm = TOOL_PERMS[name];
return perm ? this.granted.has(perm) : false;
}
}
```
### Loop with tool dispatch
```ts
let messages: Message[] = [{ role: 'user', content: userQuery }];
while (true) {
const resp = await client.messages.create({ model, tools: registry.list(), messages });
messages.push({ role: 'assistant', content: resp.content });
const toolUses = resp.content.filter(b => b.type === 'tool_use');
if (resp.stop_reason !== 'tool_use' || toolUses.length === 0) break;
const results = await Promise.all(toolUses.map(async tu => ({
type: 'tool_result' as const,
tool_use_id: tu.id,
content: await registry.dispatch(tu.name, tu.input, ctx),
})));
messages.push({ role: 'user', content: results });
}
```
### MCP server (external tool)
```ts
import { Server } from '@modelcontextprotocol/sdk/server';
const server = new Server({ name: 'fs-tools', version: '1.0' });
server.tool('read_file', {
description: 'Read file',
parameters: z.object({ path: z.string() }),
}, async ({ path }) => {
return { content: [{ type: 'text', text: await fs.readFile(path, 'utf8') }] };
});
await server.connect(new StdioServerTransport());
```
### Lazy tool loading
```ts
class LazyRegistry extends ToolRegistry {
private metaTool = {
name: 'find_tool',
description: 'Search available tools by keyword. Returns list to load.',
input_schema: { type: 'object', properties: { query: { type: 'string' }}, required: ['query'] },
};
async findTool(query: string): Promise<string[]> {
return [...this.allTools.keys()].filter(n => n.includes(query));
}
}
```
### Result truncation (token budget)
```ts
function truncate(s: string, maxTokens = 4000): string {
const approxChars = maxTokens * 4;
if (s.length <= approxChars) return s;
return s.slice(0, approxChars / 2) + `\n[... ${s.length - approxChars} chars truncated ...]\n` + s.slice(-approxChars / 2);
}
```
### Tool deprecation flow
```ts
registry.register({
name: 'old_search',
description: 'DEPRECATED — use web_search instead. Will be removed 2026-Q3.',
...
}, async (input) => {
console.warn('deprecated tool used');
return registry.dispatch('web_search', input, ctx);
});
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| < 20 tools | Static list, all in context |
| 20-100 tools | Categories + meta-tool selector |
| 100+ tools | RAG over tool descriptions + lazy load |
| Cross-process | MCP server |
| Multi-tenant | Permission gating + audit log |
**기본값**: Anthropic SDK + MCP servers + permission ACL.
## 🔗 Graph
- 부모: [[Agent Architecture]] · [[Tool Use]]
- 변형: [[MCP]] · [[Function Calling]] · [[Plugin System]]
- 응용: [[Coding Agent]] · [[Research Agent]] · [[Browser Automation]]
- Adjacent: [[S-component (State Store)]] · [[Permission Systems]]
## 🤖 LLM 활용
**언제**: tool schema 작성, dispatch boilerplate, permission policy.
**언제 X**: tool semantic 의 actual 결정 (도메인 지식).
## ❌ 안티패턴
- **Bloated context**: 모든 tools 의 always-loaded → token waste.
- **No permission**: agent 가 destructive ops 수행.
- **Vague descriptions**: LLM 의 wrong tool selection.
- **No timeout**: tool hang 의 agent freeze.
- **No retries**: transient errors 의 task fail.
## 🧪 검증 / 중복
- Verified (Anthropic tool use docs 2025, MCP spec 2024-2026).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — T-component full coverage |