feat(agent): design @typia/agent streaming function-calling harness interface#1905
Open
samchon wants to merge 2 commits into
Open
feat(agent): design @typia/agent streaming function-calling harness interface#1905samchon wants to merge 2 commits into
samchon wants to merge 2 commits into
Conversation
…nterface Introduces the interface-only (types + docs) design for `@typia/agent`, a vendor-neutral streaming function-calling harness built on typia's validation. - `IAgent`/`TypiaAgent`: `conversate()` returns an `IAgentExecution` that is an async-iterable of `IAgentResponse` parts (`text | tool`) consumed with `for await`, and returns an `IAgentTurn` outcome. - Harness surface: incremental validation (`IAgentValidation` snapshot/locked/ watch/phase), the `IAgentTool` parse->validate->feedback->execute state machine, and output-token-ceiling continuation. - `IAgentAdapter`: vendor-neutral chat-stream seam (OpenAI/Vercel), with the unified `ILlmSchema` keeping all provider knowledge inside the adapter. - Controllers/operations (`class | http | mcp | output`), `IAgentSelector` for large function counts, serializable `IAgentHistory(.Json)` memory, and a secondary `IAgentEvent` telemetry channel. - One type per file (no namespace nesting); `ARCHITECTURE.md` documents the rationale; `tsgo --noEmit` is clean. Types only; no runtime implementation yet (adapters + harness loop follow). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
Introduces the initial types + documentation only surface for a new @typia/agent package, defining a vendor-neutral streaming function-calling harness API (adapter seam, incremental validation view, tool/text parts, histories, and telemetry events) without runtime implementation.
Changes:
- Adds a new
packages/agentpackage with build scaffolding and a types-only public API (IAgent/TypiaAgent, streamingIAgentExecution,IAgentTool/IAgentTextparts). - Defines a vendor-neutral adapter contract (
IAgentAdapter+ streamed chunk model) and the harness-facing incremental validation interfaces. - Adds package-level docs (
ARCHITECTURE.md,INSTRUCTION.md) and updates repo ignore rules for research folders.
Reviewed changes
Copilot reviewed 74 out of 76 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Adds packages/agent importer dependency graph. |
| packages/agent/tsconfig.json | Adds TS build config for the new package. |
| packages/agent/src/TypiaAgent.ts | Declares the TypiaAgent facade class (types-only). |
| packages/agent/src/structures/IAgentTokenUsageOutput.ts | Adds output token usage breakdown type. |
| packages/agent/src/structures/IAgentTokenUsageInput.ts | Adds input token usage breakdown type. |
| packages/agent/src/structures/IAgentTokenUsage.ts | Adds aggregate token usage accounting type. |
| packages/agent/src/structures/IAgentTextDeltaChunk.ts | Adds adapter text-delta chunk type. |
| packages/agent/src/structures/IAgentTextContent.ts | Adds multimodal text content-part type. |
| packages/agent/src/structures/IAgentSystemPrompt.ts | Adds system-prompt override shape. |
| packages/agent/src/structures/IAgentSelectorProps.ts | Adds selector input props type. |
| packages/agent/src/structures/IAgentSelector.ts | Adds “many tools” selection strategy interface. |
| packages/agent/src/structures/IAgentRawChunk.ts | Adds raw passthrough provider chunk type. |
| packages/agent/src/structures/IAgentProps.ts | Adds agent constructor props type. |
| packages/agent/src/structures/IAgentOutputOperation.ts | Adds structured-output operation protocol type. |
| packages/agent/src/structures/IAgentOperationBase.ts | Adds shared operation header shape. |
| packages/agent/src/structures/IAgentOperation.ts | Adds operation union type. |
| packages/agent/src/structures/IAgentMessageContent.ts | Adds multimodal message content-part union. |
| packages/agent/src/structures/IAgentMessage.ts | Adds provider-neutral message type. |
| packages/agent/src/structures/IAgentMcpOperation.ts | Adds MCP-backed operation shape. |
| packages/agent/src/structures/IAgentMcpController.ts | Adds MCP controller shape. |
| packages/agent/src/structures/IAgentImageContent.ts | Adds multimodal image content-part type. |
| packages/agent/src/structures/IAgentHttpOperation.ts | Adds HTTP-backed operation shape. |
| packages/agent/src/structures/IAgentHttpExecuteProps.ts | Adds custom HTTP executor input type. |
| packages/agent/src/structures/IAgentHttpController.ts | Adds HTTP controller shape. |
| packages/agent/src/structures/IAgentFinishReason.ts | Adds normalized finish reason union. |
| packages/agent/src/structures/IAgentFinishChunk.ts | Adds adapter finish chunk (reason + usage). |
| packages/agent/src/structures/IAgentFileContent.ts | Adds multimodal file content-part type. |
| packages/agent/src/structures/IAgentErrorChunk.ts | Adds adapter error chunk type. |
| packages/agent/src/structures/IAgentConversateOptions.ts | Adds per-turn conversate options type. |
| packages/agent/src/structures/IAgentController.ts | Adds controller union type. |
| packages/agent/src/structures/IAgentContinuation.ts | Adds ceiling-continuation policy type. |
| packages/agent/src/structures/IAgentConfig.ts | Adds agent tuning configuration type. |
| packages/agent/src/structures/IAgentCompaction.ts | Adds history compaction hook type. |
| packages/agent/src/structures/IAgentClassOperation.ts | Adds class-backed operation shape. |
| packages/agent/src/structures/IAgentClassExecuteProps.ts | Adds class dispatch/proxy executor input type. |
| packages/agent/src/structures/IAgentClassController.ts | Adds class controller shape. |
| packages/agent/src/structures/IAgentChunk.ts | Adds adapter chunk union type. |
| packages/agent/src/structures/IAgentAudioContent.ts | Adds multimodal audio content-part type. |
| packages/agent/src/structures/IAgentAdapterRequest.ts | Adds vendor-neutral adapter request type. |
| packages/agent/src/structures/IAgentAdapterCapabilities.ts | Adds adapter capability advertisement type. |
| packages/agent/src/structures/IAgentAdapter.ts | Adds vendor-neutral streaming adapter interface. |
| packages/agent/src/responses/IAgentValidationState.ts | Adds incremental validation tick/state type. |
| packages/agent/src/responses/IAgentValidation.ts | Adds incremental validation interface contract. |
| packages/agent/src/responses/IAgentTurn.ts | Adds terminal turn result type returned by iterator. |
| packages/agent/src/responses/IAgentTool.ts | Adds streamed tool-call part state machine interface. |
| packages/agent/src/responses/IAgentText.ts | Adds streamed assistant text part interface. |
| packages/agent/src/responses/IAgentResponse.ts | Adds response-part discriminated union type. |
| packages/agent/src/responses/IAgentFeedbackProps.ts | Adds tool feedback/correction input type. |
| packages/agent/src/responses/IAgentExecution.ts | Adds async-iterable execution surface (+ join/abort). |
| packages/agent/src/responses/IAgentExecute.ts | Adds tool execution record type. |
| packages/agent/src/index.ts | Adds public export surface for the package. |
| packages/agent/src/IAgent.ts | Adds main agent contract interface. |
| packages/agent/src/histories/IAgentToolHistoryJson.ts | Adds serialized tool history mirror type. |
| packages/agent/src/histories/IAgentToolHistory.ts | Adds live tool history record type. |
| packages/agent/src/histories/IAgentTextHistoryJson.ts | Adds serialized text history mirror type. |
| packages/agent/src/histories/IAgentTextHistory.ts | Adds live text history record type. |
| packages/agent/src/histories/IAgentSystemHistoryJson.ts | Adds serialized system history mirror type. |
| packages/agent/src/histories/IAgentSystemHistory.ts | Adds live system history record type. |
| packages/agent/src/histories/IAgentHistoryJson.ts | Adds serialized history union type. |
| packages/agent/src/histories/IAgentHistoryBase.ts | Adds shared history header type. |
| packages/agent/src/histories/IAgentHistory.ts | Adds live history union type. |
| packages/agent/src/events/IAgentValidateEvent.ts | Adds validation telemetry event type. |
| packages/agent/src/events/IAgentUsageEvent.ts | Adds usage telemetry event type. |
| packages/agent/src/events/IAgentResponseEvent.ts | Adds adapter-response telemetry event type. |
| packages/agent/src/events/IAgentRequestEvent.ts | Adds adapter-request telemetry event type. |
| packages/agent/src/events/IAgentParseEvent.ts | Adds parse telemetry event type. |
| packages/agent/src/events/IAgentEventSource.ts | Adds event source phase union type. |
| packages/agent/src/events/IAgentEventMapper.ts | Adds event discriminator→payload mapping. |
| packages/agent/src/events/IAgentEventBase.ts | Adds shared event header type. |
| packages/agent/src/events/IAgentEvent.ts | Adds event union type. |
| packages/agent/src/events/IAgentContinuationEvent.ts | Adds continuation telemetry event type. |
| packages/agent/rollup.config.mjs | Adds rollup config forwarding to repo config. |
| packages/agent/package.json | Adds new package manifest and publish config. |
| packages/agent/INSTRUCTION.md | Adds package-level instruction/notes document. |
| packages/agent/ARCHITECTURE.md | Adds architecture/design documentation for the new package. |
| .gitignore | Ignores .repositories/ research clone folder. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,36 @@ | |||
| 나는 `@typia/agent` 라이브러리를 만들고자 하노라. | |||
|
|
|||
| 다음 두 가지 아티클을 핵심 철학으로 삼을 것이며, 이 중 특히 Lenient JSDN parsing + function calling 내지 structured output의 streaming을 위해 달리는 것이니라. | |||
| - https://typia.io/blog/function-calling-harness-qwen-meetup-korea/ | ||
| - https://typia.io/blog/function-calling-harness-2-cot-compliance/ | ||
|
|
||
| 그리고 `D:/github/wrtnlabs/agentica`를 보면, 이벤트에 기반하여 functino calling 프레임워크를 만들었음을 알 수 있다. `@typia/agent`도 이 중 `MicroAgentica`와 같은 기능을 만들 것이되, agentica처럼 tools 기능을 쓰는게 아니라, text streaming response를 통해 출력 가능 최대 토큰량의 제한을 뛰어넘을 것이며, function callling harness에 나오는 incremental validation을 이룩할 것이다. |
| } | ||
| } else if (r.type === "text") { | ||
| for await (const piece of r.stream()) { | ||
| consoole.log("piece", piece); |
Comment on lines
+42
to
+48
| "files": [ | ||
| "README.md", | ||
| "INSTRUCTION.md", | ||
| "package.json", | ||
| "lib", | ||
| "src" | ||
| ], |
Comment on lines
+17
to
+18
| /** 함수 이름. */ | ||
| function: string; |
Comment on lines
+1
to
+14
| import { IAgentTokenUsage } from "../structures/IAgentTokenUsage"; | ||
| import { IAgentEventBase } from "./IAgentEventBase"; | ||
| import { IAgentEventSource } from "./IAgentEventSource"; | ||
|
|
||
| /** | ||
| * 보고된 usage를 담은, 완료된 adapter 응답. | ||
| * | ||
| * @author Jeongho Nam - https://github.com/samchon | ||
| */ | ||
| export interface IAgentResponseEvent extends IAgentEventBase<"response"> { | ||
| source: IAgentEventSource; | ||
| usage: IAgentTokenUsage; | ||
| finishReason: string; | ||
| } |
Comment on lines
+1
to
+14
| import { IAgentEventBase } from "./IAgentEventBase"; | ||
|
|
||
| /** | ||
| * Ceiling-continuation이 수행됨(출력이 단일 completion을 초과). | ||
| * | ||
| * @author Jeongho Nam - https://github.com/samchon | ||
| */ | ||
| export interface IAgentContinuationEvent extends IAgentEventBase<"continuation"> { | ||
| /** 현재 답변 내 이 continuation의 1-based 인덱스. */ | ||
| index: number; | ||
|
|
||
| /** 이를 trigger한 finish 사유(대개 `"length"`). */ | ||
| trigger: string; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
@typia/agent의 인터페이스 설계(타입 + 문서 전용) 1차 산출물. typia validation 위에 구축된, 벤더 중립 streaming function-calling harness의 타입 표면을 확정한다.핵심 use-case가 타입 안전·자동완성되도록 모든 타입을 정렬했다:
Scope
IAgent/TypiaAgent—conversate()가IAgentExecution(async-iterable ofIAgentResponse) 반환, iterator는IAgentTurn결과를 return.IAgentValidation: snapshot/locked/watch/phase),IAgentToolparse→validate→feedback→execute state machine, output-token 천장 continuation.IAgentAdapter— OpenAI/Vercel를 한 줄로 갈아끼우는 벤더 중립 chat-stream 시임. 통합ILlmSchema덕에 provider 지식은 adapter 안에만.class | http | mcp | output), 대규모 함수용IAgentSelector, 직렬화 가능한IAgentHistory(.Json)메모리, 부차IAgentEventtelemetry.packages/agent/ARCHITECTURE.md.Deferred
OpenAiAdapter/VercelAdapter+ harness loop는 후속).tests/test-agent/)는 후속.Test plan
tsgo --noEmit -p packages/agent/tsconfig.json→ 클린(전체 타입 표면 정합).prettier --write적용(import 정렬 + repo의prettier-plugin-jsdoc).pnpm build(ttsc) 검증은 후속 작업이 필요할 수 있다.🤖 Generated with Claude Code