a2ui-project / a2ui-project/a2ui

Unify System Instruction Generation for Text and Tool Output Modes

未关闭
#1,289 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
component: agent_sdk P2 type: feature/enhancement
主要语言
TypeScript
星标
16.4k
派生
1.3k
平均合并
2 天 13 小时
30 天内合并 PR
134

描述

## Context

Currently, `a2ui.schema.manager.generate_system_prompt` and `send_a2ui_to_client_toolset` provide two separate paths for instructing the LLM on how to handle A2UI. This makes it difficult for developers to know exactly what is being sent in the final system instruction.

## Problem

- Developers need to set paremeters `include_schema` and `include_examples` to False to avoid conflicts with tool-based instructions, which creates ambiguity when a toolset is already providing that context.
- Appending multiple strings from different modules makes prompt tuning and debugging difficult.

## Proposed Sollution

Refactor the prompt generation logic into a unified "Skill" or configuration object.

- ~~Introduce an explicit `A2UIOutputMode` enum: TEXT (for direct schema injection) and TOOL (for tool-calling environments).~~
- ~~Simplify the API so that system instructions are generated based on the selected mode, preventing accidental double-injection of schemas or instructions.~~

After reviewing both https://github.com/google/A2UI/pull/1466 and https://github.com/google/A2UI/pull/1465 together, I want to propose a design refinement that addresses the parameter naming issue and consolidates both concerns cleanly.

- Repurpose `output_mode` enum for the output strictness level.
- Introduce a new `schema_injection_mode` enum for where and when the schema should be injected.

```python
class A2UISchemaInjectionMode(Enum):
"""Where/when the schema is injected."""
EMBEDDED = "embedded" # Schema in system prompt (upfront, one-time)
TOOL = "tool" # Schema injected per-request by toolset
NONE = "none" # No schema injection (default)

class A2UIOutputMode(Enum):
"""How the LLM should prioritize A2UI vs. text."""
A2UI_FIRST = "a2ui_first" # A2UI blocks first, minimal text after
TEXT_FIRST = "text_first" # Text and A2UI can be interleaved (default)
# Future: STRICT_A2UI, A2UI_ONLY for even stricter modes
```

贡献指南

打开贡献指南

调研方向

Examine the `a2ui.schema.manager.generate_system_prompt` and `send_a2ui_to_client_toolset` functions to understand the current separate prompt generation paths. Review the linked pull requests #1466 and #1465 for context on the proposed design. The goal is to create a unified configuration object, likely a 'Skill', that handles schema injection based on a new `schema_injection_mode` enum. Start by locating the relevant modules in the codebase and understanding how system instructions are currently assembled.

由索引模型根据 Issue 内容生成。

评估

技术栈
typescript
领域
backend-api-design
Issue 类型
重构
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。