Skip to content

Commit 6c9826f

Browse files
feat(tasks): Add --include-history flag to tasks list command (#20)
* feat(tasks): Add --include-history flag to tasks list command - Add --include-history flag to conditionally show conversation history - By default, tasks list now excludes history for cleaner output - Users can still get full details with tasks get <task-id> - Update README.md with documentation for the new flag Fixes #19 Co-authored-by: Eden Reich <[email protected]> * chore: Remove redundant inline comments --------- Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: Eden Reich <[email protected]>
1 parent f5afc25 commit 6c9826f

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ output: yaml # or json
169169
- `--context-id`: Filter by context ID
170170
- `--limit`: Maximum number of tasks to return (default: 50)
171171
- `--offset`: Number of tasks to skip (default: 0)
172+
- `--include-history`: Include conversation history in the output (default: false)
172173

173174
#### Task Get Options
174175

@@ -238,6 +239,18 @@ $ a2a tasks list --state working --limit 5
238239
Role: user
239240
```
240241

242+
#### Include conversation history in task list
243+
244+
By default, `tasks list` excludes conversation history to keep output manageable. Use `--include-history` to show complete task data:
245+
246+
```bash
247+
# Without history (default - cleaner output)
248+
$ a2a tasks list --limit 1
249+
250+
# With history (complete task data including conversation)
251+
$ a2a tasks list --limit 1 --include-history
252+
```
253+
241254
#### View detailed task information
242255

243256
```bash

cli/cli.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ func init() {
113113
listTasksCmd.Flags().String("context-id", "", "Filter by context ID")
114114
listTasksCmd.Flags().Int("limit", 50, "Maximum number of tasks to return")
115115
listTasksCmd.Flags().Int("offset", 0, "Number of tasks to skip")
116+
listTasksCmd.Flags().Bool("include-history", false, "Include conversation history in the output")
116117
getTaskCmd.Flags().Int("history-length", 0, "Number of history messages to include")
117118
submitTaskCmd.Flags().String("context-id", "", "Context ID for the task (optional, will generate new context if not provided)")
118119
submitTaskCmd.Flags().String("task-id", "", "Task ID to resume (optional)")
@@ -350,6 +351,7 @@ var listTasksCmd = &cobra.Command{
350351
contextID, _ := cmd.Flags().GetString("context-id")
351352
limit, _ := cmd.Flags().GetInt("limit")
352353
offset, _ := cmd.Flags().GetInt("offset")
354+
includeHistory, _ := cmd.Flags().GetBool("include-history")
353355

354356
params := adk.TaskListParams{
355357
Limit: limit,
@@ -382,10 +384,27 @@ var listTasksCmd = &cobra.Command{
382384
return fmt.Errorf("failed to unmarshal task list: %w", err)
383385
}
384386

387+
tasks := taskList.Tasks
388+
if !includeHistory {
389+
var filteredTasks []adk.Task
390+
for _, task := range tasks {
391+
filteredTask := adk.Task{
392+
ID: task.ID,
393+
Kind: task.Kind,
394+
ContextID: task.ContextID,
395+
Status: task.Status,
396+
Artifacts: task.Artifacts,
397+
Metadata: task.Metadata,
398+
}
399+
filteredTasks = append(filteredTasks, filteredTask)
400+
}
401+
tasks = filteredTasks
402+
}
403+
385404
output := map[string]any{
386-
"tasks": taskList.Tasks,
405+
"tasks": tasks,
387406
"total": taskList.Total,
388-
"showing": len(taskList.Tasks),
407+
"showing": len(tasks),
389408
}
390409

391410
return printFormatted(output)

0 commit comments

Comments
 (0)