Skip to content

Commit 60e92f3

Browse files
kevinelliottclaude
andcommitted
Add dual summary generation (v0.5.1)
Dual Summary Feature: - Generate both short (1-2 sentence) and full summaries in a single LLM query - Consistent field naming: ShortSummary and Summary across all structures - Structured parsing with SHORT: and FULL: markers for reliability - Graceful fallback: Auto-extracts short summary if parsing fails - Summaries persisted in conversation state and bridge events - New GetSummary() method on Orchestrator for programmatic access Implementation: - Updated SummaryMetadata (bridge events): short_summary + summary fields - Updated StateMetadata (state files): short_summary + summary fields - Added parseDualSummary() function with robust parsing logic - Modified generateSummary() prompt to request both summaries - Comprehensive tests (14 test cases) covering parsing edge cases Benefits: - Single API call generates both summaries (cost & time efficient) - Easy parsing with structured markers - Ready for AgentPipe Web UI integration - Ideal for list views (short) and detail pages (full) Documentation: - Updated README with dual summary section - Updated streaming section to highlight dual summaries in events - Finalized CHANGELOG for v0.5.1 release All tests passing. Ready for release. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent c0e18c0 commit 60e92f3

File tree

7 files changed

+649
-43
lines changed

7 files changed

+649
-43
lines changed

CHANGELOG.md

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,152 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.5.1] - 2025-01-26
11+
12+
### Added
13+
- **Dual Summary Generation (Short + Full)**
14+
- Conversations now generate both short (1-2 sentences) and full summaries in a single LLM query
15+
- Structured prompt format: `SHORT: [summary]` and `FULL: [summary]` for reliable parsing
16+
- Consistent field naming across bridge events and conversation state:
17+
- `ShortSummary` - Concise 1-2 sentence summary ideal for list views
18+
- `Summary` - Comprehensive detailed summary for detail pages
19+
- Fallback logic: If parsing fails, extracts first 1-2 sentences for short summary
20+
- Summary data persisted in conversation state files (`~/.agentpipe/states/`)
21+
- New `GetSummary()` method on Orchestrator for programmatic access
22+
- Benefits:
23+
- ✅ Single API call generates both summaries (cost & time efficient)
24+
- ✅ Easy parsing with structured markers
25+
- ✅ Graceful degradation on parse failures
26+
- ✅ Ready for AgentPipe Web UI integration
27+
28+
- **CLI Model Specification for --agents Flag**
29+
- Three flexible formats for specifying agents via CLI:
30+
- `type` - Auto-generated name with default model
31+
- `type:name` - Custom name with default model (existing format)
32+
- `type:model:name` - Custom name with specific model (NEW)
33+
- Model validation with comprehensive error handling:
34+
- Validates agent types against registry
35+
- Checks if agent supports model specification
36+
- Enforces required model for OpenRouter
37+
- Prevents model specification for unsupported agents (kimi, cursor, amp)
38+
- Model support matrix:
39+
-**Optional**: claude, gemini, copilot, qwen, factory, qoder, codex, groq, crush
40+
-**Required**: openrouter (API-based agent)
41+
-**Not supported**: kimi, cursor, amp, opencode
42+
- All CLI adapters updated to use `--model` flag when Config.Model is set
43+
- Examples:
44+
```bash
45+
# Use default models
46+
agentpipe run -a claude:Alice -a gemini:Bob
47+
48+
# Specify models explicitly
49+
agentpipe run -a claude:claude-sonnet-4-5:Architect \
50+
-a gemini:gemini-2.5-pro:Reviewer
51+
52+
# OpenRouter with provider/model format
53+
agentpipe run -a openrouter:anthropic/claude-sonnet-4-5:Assistant \
54+
-a openrouter:google/gemini-2.5-pro:Critic
55+
```
56+
57+
### Technical Details
58+
- **New Module**: `cmd/model_validation.go`
59+
- `ModelSupport` struct defining support and requirement status
60+
- `agentModelSupport` map for all agent types
61+
- Validation functions:
62+
- `validateAgentType()` - Checks agent type exists
63+
- `validateModelForAgent()` - Validates model specification for agent
64+
- `validateModelInRegistry()` - Warns if model not in provider registry
65+
- `checkModelRequired()` - Enforces required model for certain agents
66+
- `parseAgentSpecWithModel()` - Parses all three formats with validation
67+
- **Updated**: `cmd/run.go`
68+
- `parseAgentSpec()` now uses `parseAgentSpecWithModel()`
69+
- Populates `agent.AgentConfig.Model` field from CLI input
70+
- Comprehensive error messages for invalid specifications
71+
- **Updated Adapters** (9 total):
72+
- `pkg/adapters/claude.go` - Added --model flag support (SendMessage + StreamMessage)
73+
- `pkg/adapters/groq.go` - Added --model flag support (SendMessage + StreamMessage)
74+
- `pkg/adapters/crush.go` - Added --model flag support (SendMessage + StreamMessage)
75+
- Already had support: qwen, factory, qoder, codex, copilot, gemini
76+
- **Comprehensive Tests**: `cmd/run_test.go`
77+
- `TestParseAgentSpec()` - 30+ test cases covering all formats
78+
- `TestParseAgentSpecWithModel()` - Format parsing validation
79+
- `TestValidateAgentType()` - Agent type validation
80+
- `TestValidateModelForAgent()` - Model support validation
81+
- Tests for error cases: empty specs, unknown types, unsupported models, required models
82+
83+
### Benefits
84+
- 🚀 **Simplified Model Selection**: Specify models directly via CLI without YAML
85+
- 🔍 **Smart Validation**: Immediate feedback for invalid agent/model combinations
86+
- 📝 **Clear Error Messages**: Actionable error messages for misconfigurations
87+
- 🎯 **Type Safety**: Compile-time and runtime validation of agent specifications
88+
- 🔄 **Backward Compatible**: Existing `type:name` format still works
89+
- 🌐 **OpenRouter Integration**: Seamless model specification for API-based agents
90+
91+
### Documentation
92+
- README.md: New "Agent specification formats" section with:
93+
- Format descriptions and examples
94+
- Model support matrix table
95+
- Comprehensive CLI examples
96+
- Error examples showing what not to do
97+
- Updated run command flags documentation to show all three formats
98+
99+
## [v0.6.0] - 2025-10-25
100+
101+
### Added
102+
- **OpenRouter API Support - First API-Based Agent**
103+
- New `openrouter` agent type for direct API integration without CLI dependencies
104+
- Access 400+ models from multiple providers through a unified API
105+
- No CLI installation required - just set `OPENROUTER_API_KEY` environment variable
106+
- Support for models from Anthropic, OpenAI, Google, DeepSeek, Groq, and many more
107+
- Real-time token usage and accurate cost tracking from API responses
108+
- Streaming and non-streaming message support via Server-Sent Events (SSE)
109+
- Smart model matching with provider registry integration
110+
- Example configurations:
111+
- `examples/openrouter-conversation.yaml` - Multi-provider conversation
112+
- `examples/openrouter-solo.yaml` - Single agent reasoning task
113+
114+
### Technical Details
115+
- **New Package**: `pkg/client/` for HTTP client infrastructure
116+
- `openai_compat.go` - Generic HTTP client for OpenAI-compatible APIs
117+
- Support for streaming (SSE) and non-streaming requests
118+
- Retry logic with exponential backoff (1s, 2s, 4s)
119+
- Bearer token authentication
120+
- Comprehensive error handling with retry strategies
121+
- Context cancellation support
122+
- **New Adapter**: `pkg/adapters/openrouter.go`
123+
- Implements complete Agent interface using HTTP API
124+
- Converts AgentPipe messages to OpenAI Chat Completions format
125+
- Integrates with provider registry for cost calculation
126+
- Automatic API key detection from `$OPENROUTER_API_KEY`
127+
- Health check via minimal API request
128+
- GetCLIVersion() returns "N/A (API)" for API-based agents
129+
- **Comprehensive Test Coverage**:
130+
- `pkg/client/openai_compat_test.go` - HTTP client tests with mocked responses
131+
- `pkg/adapters/openrouter_test.go` - Agent adapter tests
132+
- Integration tests (skipped without API key)
133+
- >80% code coverage
134+
135+
### Benefits
136+
- ✅ **No CLI Dependencies**: Use models without installing any CLI tools
137+
- 🚀 **Direct API Access**: Lower latency, more reliable than CLI execution
138+
- 🌍 **Comprehensive Model Support**: 400+ models from multiple providers
139+
- 💰 **Accurate Pricing**: Real token counts from API responses for precise cost tracking
140+
- 📡 **Streaming Support**: Real-time response streaming via SSE
141+
- 🔌 **Unified Architecture**: Same Agent interface for both CLI and API-based agents
142+
- 🛤️ **Foundation for Future**: Paves the way for direct Anthropic API, Google AI API, Groq API, etc.
143+
144+
### Architecture Impact
145+
- Establishes pattern for API-based agents separate from CLI-based agents
146+
- Creates reusable HTTP client for future OpenAI-compatible providers
147+
- Maintains backward compatibility - all existing CLI-based agents unchanged
148+
- Demonstrates hybrid approach: AgentPipe can use both CLI tools and direct APIs
149+
150+
### Documentation
151+
- README.md: New "Using OpenRouter (API-Based Agents)" section
152+
- Detailed setup instructions with environment variable configuration
153+
- Model examples and use case recommendations
154+
- Links to OpenRouter documentation and model list
155+
10156
## [v0.5.0] - 2025-10-25
11157
12158
### Added

README.md

Lines changed: 159 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ All agents now use a **standardized interaction pattern** with structured three-
3737
-**Groq** - Fast AI code assistant powered by Groq LPUs (Lightning Processing Units)
3838
-**Kimi** (Moonshot AI) - Interactive AI agent with advanced reasoning (interactive-first CLI)
3939
-**OpenCode** (SST) - AI coding agent built for the terminal (non-interactive run mode)
40+
-**OpenRouter** - Unified API access to 400+ models from multiple providers (API-based, no CLI required) 🌐 **API-based**
4041
-**Qoder** - Agentic coding platform with enhanced context engineering
4142
-**Qwen** (Alibaba) - Multilingual capabilities
4243
-**Ollama** - Local LLM support (planned)
@@ -97,17 +98,25 @@ All agents now use a **standardized interaction pattern** with structured three-
9798

9899
See [CHANGELOG.md](CHANGELOG.md) for detailed version history and release notes.
99100

100-
**Latest Release**: v0.4.9 - Crush CLI support
101+
**Latest Release**: v0.6.0 - OpenRouter API Support
101102

102-
**What's New in v0.4.9**:
103+
**What's New in v0.6.0**:
103104

104-
💘 **Crush CLI Support (Charmbracelet)**:
105-
- **New Agent Adapter**: Full support for Charm's Crush CLI
106-
- Install: `brew install charmbracelet/tap/crush` (macOS) or `go install github.com/charmbracelet/crush@latest`
107-
- Terminal-first AI coding assistant with beautiful TUI
108-
- Multi-provider support (Anthropic, OpenAI, Groq, Gemini, and more)
109-
- Supports stdin-based message passing
110-
- Complete integration with AgentPipe's multi-agent conversation system
105+
🌐 **OpenRouter API Support - First API-Based Agent**:
106+
- **New Agent Type**: Direct API integration without CLI dependencies
107+
- Access 400+ models from multiple providers through a unified API
108+
- No CLI installation required - just set `OPENROUTER_API_KEY`
109+
- Support for models from Anthropic, OpenAI, Google, DeepSeek, and more
110+
- Real-time token usage and accurate cost tracking from API responses
111+
- Streaming and non-streaming message support
112+
- Smart model matching with provider registry integration
113+
- **Example Configurations**:
114+
- `examples/openrouter-conversation.yaml` - Multi-provider conversation
115+
- `examples/openrouter-solo.yaml` - Single agent testing
116+
- **Foundation for Future API Agents**: Paves the way for direct Anthropic API, Google AI API, etc.
117+
118+
**Previous Release - v0.4.9** (2025-10-25): Crush CLI support
119+
- Full support for Charm's Crush CLI with multi-provider capabilities
111120

112121
**Previous Release - v0.4.8** (2025-10-25): Fixed GitHub API rate limiting
113122
- PyPI integration for Kimi, npm registry for Qwen
@@ -260,6 +269,80 @@ agentpipe run -a claude:Agent1 -a gemini:Agent2 \
260269
--max-turns 10 \
261270
--timeout 45 \
262271
--prompt "What is consciousness?"
272+
273+
# Specify models for agents that support it
274+
agentpipe run -a claude:claude-sonnet-4-5:Alice -a gemini:gemini-2.5-pro:Bob
275+
276+
# Use OpenRouter with specific models
277+
agentpipe run -a openrouter:anthropic/claude-sonnet-4-5:Assistant \
278+
-a openrouter:google/gemini-2.5-pro:Reviewer \
279+
--prompt "Design a microservices architecture"
280+
```
281+
282+
### Agent specification formats
283+
284+
AgentPipe supports three formats for specifying agents via the `--agents` / `-a` flag:
285+
286+
1. **`type`** - Use agent type with auto-generated name
287+
```bash
288+
agentpipe run -a claude -a gemini
289+
# Creates: claude-agent-1, gemini-agent-2
290+
```
291+
292+
2. **`type:name`** - Use agent type with custom name (uses default model)
293+
```bash
294+
agentpipe run -a claude:Alice -a gemini:Bob
295+
# Creates: Alice (Claude), Bob (Gemini)
296+
```
297+
298+
3. **`type:model:name`** - Use agent type with specific model and custom name
299+
```bash
300+
agentpipe run -a claude:claude-sonnet-4-5:Architect \
301+
-a gemini:gemini-2.5-pro:Reviewer
302+
# Creates: Architect (Claude Sonnet 4.5), Reviewer (Gemini 2.5 Pro)
303+
```
304+
305+
**Model Support by Agent Type:**
306+
307+
| Agent Type | Model Support | Required | Example Models |
308+
|------------|--------------|----------|----------------|
309+
| `claude` | ✅ Optional | No | `claude-sonnet-4-5`, `claude-opus-4` |
310+
| `gemini` | ✅ Optional | No | `gemini-2.5-pro`, `gemini-2.5-flash` |
311+
| `copilot` | ✅ Optional | No | `gpt-4o`, `gpt-4-turbo` |
312+
| `qwen` | ✅ Optional | No | `qwen-plus`, `qwen-turbo` |
313+
| `factory` | ✅ Optional | No | `claude-sonnet-4-5`, `gpt-4o` |
314+
| `qoder` | ✅ Optional | No | `claude-sonnet-4-5`, `gpt-4o` |
315+
| `codex` | ✅ Optional | No | `gpt-4o`, `gpt-4-turbo` |
316+
| `groq` | ✅ Optional | No | `llama3-70b`, `mixtral-8x7b` |
317+
| `crush` | ✅ Optional | No | `deepseek-r1`, `qwen-2.5` |
318+
| `openrouter` |**Required** | Yes | `anthropic/claude-sonnet-4-5`, `google/gemini-2.5-pro` |
319+
| `kimi` | ❌ Not supported | No | N/A |
320+
| `cursor` | ❌ Not supported | No | N/A |
321+
| `amp` | ❌ Not supported | No | N/A |
322+
323+
**Examples:**
324+
325+
```bash
326+
# Use default models
327+
agentpipe run -a claude:Alice -a gemini:Bob
328+
329+
# Specify models explicitly
330+
agentpipe run -a claude:claude-sonnet-4-5:Alice \
331+
-a gemini:gemini-2.5-pro:Bob
332+
333+
# Mix default and explicit models
334+
agentpipe run -a claude:Architect \
335+
-a gemini:gemini-2.5-flash:Reviewer
336+
337+
# OpenRouter requires model specification
338+
agentpipe run -a openrouter:anthropic/claude-sonnet-4-5:Claude \
339+
-a openrouter:google/gemini-2.5-pro:Gemini
340+
341+
# Error: OpenRouter without model
342+
agentpipe run -a openrouter:Assistant # ❌ Will fail
343+
344+
# Error: Agents that don't support models
345+
agentpipe run -a kimi:some-model:Assistant # ❌ Will fail
263346
```
264347

265348
### Using configuration files
@@ -327,7 +410,7 @@ Start a conversation between agents.
327410

328411
**Flags:**
329412
- `-c, --config`: Path to YAML configuration file
330-
- `-a, --agents`: List of agents (format: `type:name`)
413+
- `-a, --agents`: List of agents (formats: `type`, `type:name`, or `type:model:name`)
331414
- `-m, --mode`: Conversation mode (default: round-robin)
332415
- `--max-turns`: Maximum conversation turns (default: 10)
333416
- `--timeout`: Response timeout in seconds (default: 30)
@@ -580,6 +663,60 @@ Gemini gemini 2 gemini-2.5-pro gemini-2.
580663
OpenAI openai 14 gpt-5 gpt-5-mini
581664
```
582665

666+
### Using OpenRouter (API-Based Agents)
667+
668+
OpenRouter provides unified API access to 400+ models from multiple providers without requiring CLI installations. This is AgentPipe's first API-based agent type.
669+
670+
**Setup:**
671+
672+
1. **Get an API Key**: Sign up at [openrouter.ai](https://openrouter.ai) and obtain your API key
673+
2. **Set Environment Variable**:
674+
```bash
675+
export OPENROUTER_API_KEY=your-api-key-here
676+
```
677+
3. **Create a Configuration**:
678+
```yaml
679+
version: "1.0"
680+
681+
agents:
682+
- id: claude-agent
683+
type: openrouter
684+
name: "Claude via OpenRouter"
685+
model: anthropic/claude-sonnet-4-5
686+
prompt: "You are a helpful assistant"
687+
temperature: 0.7
688+
max_tokens: 1000
689+
```
690+
4. **Run**:
691+
```bash
692+
agentpipe run -c your-config.yaml
693+
```
694+
695+
**Available Models** (examples):
696+
- `anthropic/claude-sonnet-4-5` - Claude Sonnet 4.5
697+
- `google/gemini-2.5-pro` - Gemini 2.5 Pro
698+
- `openai/gpt-5` - GPT-5
699+
- `deepseek/deepseek-r1` - DeepSeek R1
700+
- And 400+ more - see [openrouter.ai/docs/models](https://openrouter.ai/docs/models)
701+
702+
**Features:**
703+
- ✅ No CLI installation required
704+
- ✅ Real-time token usage from API responses
705+
- ✅ Accurate cost tracking via provider registry
706+
- ✅ Streaming support for real-time responses
707+
- ✅ Access to latest models without CLI updates
708+
- ✅ Multi-provider conversations in a single config
709+
710+
**Example Configurations:**
711+
- `examples/openrouter-conversation.yaml` - Multi-provider conversation
712+
- `examples/openrouter-solo.yaml` - Single agent reasoning task
713+
714+
**Use Cases:**
715+
- Testing models without installing multiple CLIs
716+
- Production deployments with consistent API access
717+
- Cross-provider comparisons in single conversations
718+
- Access to models not available via CLI
719+
583720
### `agentpipe agents`
584721

585722
Manage AI agent CLI installations with version checking and upgrade capabilities.
@@ -862,6 +999,16 @@ The summary includes:
862999
- Total time spent (formatted as ms/s/m:s)
8631000
- Total estimated cost
8641001

1002+
**AI-Generated Conversation Summaries:**
1003+
AgentPipe automatically generates dual summaries of conversations:
1004+
- **Short Summary**: Concise 1-2 sentence overview ideal for list views
1005+
- **Full Summary**: Comprehensive detailed summary capturing key points and insights
1006+
- **Single API Call**: Both summaries generated efficiently in one LLM query
1007+
- **Structured Parsing**: Reliable extraction using `SHORT:` and `FULL:` markers
1008+
- **Graceful Fallback**: Auto-extracts short summary from first sentences if parsing fails
1009+
- **Persisted**: Summaries saved in conversation state files and bridge events
1010+
- **Programmatic Access**: `GetSummary()` method on Orchestrator for custom integrations
1011+
8651012
## TUI Interface
8661013

8671014
The enhanced TUI provides a rich, interactive experience for managing multi-agent conversations:
@@ -1356,8 +1503,9 @@ AgentPipe can stream live conversation events to AgentPipe Web for browser viewi
13561503
- **Four Event Types**:
13571504
- `conversation.started` - Conversation begins with agent participants and system info
13581505
- `message.created` - Agent sends a message with full metrics (tokens, cost, duration)
1359-
- `conversation.completed` - Conversation ends with summary statistics
1506+
- `conversation.completed` - Conversation ends with dual summaries (short + full) and statistics
13601507
- `conversation.error` - Agent or orchestration errors
1508+
- **AI-Generated Summaries**: Dual summaries (short & full) automatically generated and included in completion events
13611509
- **Comprehensive Metrics**: Track turns, tokens, costs, and duration in real-time
13621510
- **System Information**: OS, version, architecture, AgentPipe version, agent CLI versions
13631511
- **Production-Ready**: Retry logic with exponential backoff, >80% test coverage

0 commit comments

Comments
 (0)