a2aproject / a2aproject/a2a-cli
feat: add interactive chat for multi-turn agent sessions
- 主要语言
- Go
- 星标
- 95
- 派生
- 4
- 平均合并
- 3 天 2 小时
- 30 天内合并 PR
- 24
描述
**Goal:** Give a human a simple, interactive multi-turn conversation with an agent from the terminal, without re-typing identifiers on every turn.
**User story:** As a developer exploring an agent, I want an interactive chat that remembers the conversation, so that I can go back and forth without re-passing --context-id and --task-id each turn.
**Priority:** P2 · **Area:** CLI code
## Problem
Driving a multi-turn conversation today means running `a2a send` repeatedly and manually carrying `--context-id` (and `--task-id` while a task is paused) from one command's output into the next. There is no interactive session command:
```
$ a2a chat --help
Error: unknown command "chat" for "a2a"
```
## Proposed behavior
Add an interactive `a2a chat` command for a back-and-forth session with one agent:
```
a2a chat -a
```
- Reads a message from the prompt, sends it, prints the agent's reply, and loops.
- **Carries the `contextId` across turns automatically** (and the active `taskId` while a task is interrupted), so the user never copies identifiers by hand — the CLI stays stateless between processes, but a live `chat` session holds this in memory for its own duration only.
- On `INPUT_REQUIRED`, prompts for the reply and continues the same task; on `AUTH_REQUIRED`, stops and explains what's needed.
- Prints the `taskId`/`contextId` so a user can resume later with `a2a send`.
- Plain, readable output; exits cleanly on EOF/`Ctrl-D` or a `/quit` command.
## Interactive-safety requirements
- `chat` is interactive-only: it **must auto-degrade to non-interactive `send` behavior when stdout is not a terminal**, and must never block waiting on input in a pipe/CI context.
- It must not be the default command; a script's behavior must not change because it happened to run in a terminal.
## Who benefits
- Developers exploring or debugging an agent conversationally.
- Anyone giving a quick demo of an agent from the terminal.
## Acceptance criteria
- [ ] `a2a chat -a ` runs a multi-turn loop, carrying `contextId`/`taskId` automatically.
- [ ] Handles `INPUT_REQUIRED` (prompt + continue) and `AUTH_REQUIRED` (stop + explain).
- [ ] Auto-degrades / does not block when stdout is not a terminal.
- [ ] `/quit` and EOF exit cleanly; the last `taskId`/`contextId` are printed for later resume.
## Environment
- CLI version: `a2a version v0.0.0-…1e29dfe94f95+dirty`
- OS: Linux x86_64
## Notes
This is an ergonomics layer built entirely on top of the existing `send`/`task` behavior — it introduces no new protocol behavior, only an interactive front-end that manages identifiers for the length of the session.
贡献指南
评估
这个 Issue 还没有评估数据。