Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cmd/root/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/docker/cagent/pkg/creator"
"github.com/docker/cagent/pkg/runtime"
"github.com/docker/cagent/pkg/session"
"github.com/docker/cagent/pkg/sessiontitle"
"github.com/docker/cagent/pkg/telemetry"
"github.com/docker/cagent/pkg/tui"
)
Expand Down Expand Up @@ -73,6 +74,13 @@ func (f *newFlags) runNewCommand(cmd *cobra.Command, args []string) error {
}

func runTUI(ctx context.Context, rt runtime.Runtime, sess *session.Session, opts ...app.Opt) error {
// For local runtime, create and pass a title generator
if localRt, ok := rt.(*runtime.LocalRuntime); ok {
if model := localRt.CurrentAgent().Model(); model != nil {
opts = append(opts, app.WithTitleGenerator(sessiontitle.New(model)))
}
}

a := app.New(ctx, rt, sess, opts...)
m := tui.New(ctx, a)

Expand Down
25 changes: 25 additions & 0 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ During TUI sessions, you can use special slash commands. Type `/` to see all ava
| `/shell` | Start a shell |
| `/star` | Toggle star on current session |
| `/think` | Toggle thinking/reasoning mode |
| `/title` | Set or regenerate session title (usage: /title [new title]) |
| `/yolo` | Toggle automatic approval of tool calls |

#### Runtime Model Switching
Expand All @@ -195,6 +196,30 @@ The `/model` command (or `ctrl+m`) allows you to change the AI model used by the

To revert to the agent's default model, select the model marked with "(default)" in the picker.

#### Session Title Editing

You can customize session titles to make them more meaningful and easier to find later. By default, cagent automatically generates titles based on your first message, but you can override or regenerate them at any time.

**Using the `/title` command:**

```
/title # Regenerate title using AI (based on at most the last 2 user messages)
/title My Custom Title # Set a specific title
```

**Using the sidebar:**

In the TUI, you can click on the pencil icon (✎) next to the session title in the sidebar to edit it inline:

1. Click the pencil icon next to the title
2. Type your new title
3. Press Enter to save, or Escape to cancel

**Notes:**
- Manually set titles are preserved and won't be overwritten by auto-generation
- Title changes are persisted immediately to the session
- Works with both local and remote runtimes

## 🔧 Configuration Reference

### Agent Properties
Expand Down
4 changes: 2 additions & 2 deletions e2e/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestRuntime_OpenAI_Basic(t *testing.T) {

response := sess.GetLastAssistantMessageContent()
assert.Equal(t, "2 + 2 equals 4.", response)
assert.Equal(t, "Simple Math: Addition of 2 and 2", sess.Title)
// Title generation is now handled by pkg/app or pkg/server, not the runtime
}

func TestRuntime_Mistral_Basic(t *testing.T) {
Expand All @@ -55,5 +55,5 @@ func TestRuntime_Mistral_Basic(t *testing.T) {

response := sess.GetLastAssistantMessageContent()
assert.Equal(t, "The sum of 2 + 2 is 4.", response)
assert.Equal(t, "Math Basics: Simple Addition", sess.Title)
// Title generation is now handled by pkg/app or pkg/server, not the runtime
}
2 changes: 1 addition & 1 deletion e2e/testdata/cassettes/TestRuntime_Mistral_Basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ interactions:
proto_minor: 1
content_length: 0
host: api.mistral.ai
body: '{"messages":[{"content":"You are a helpful AI assistant that generates concise, descriptive titles for conversations. You will be given a conversation history and asked to create a single-line title that captures the main topic. Never use newlines or line breaks in your response.","role":"system"},{"content":"Based on the following message a user sent to an AI assistant, generate a short, descriptive title (maximum 50 characters) that captures the main topic or purpose of the conversation. Return ONLY the title text on a single line, nothing else. Do not include any newlines, explanations, or formatting.\n\nUser message: What''s 2+2?\n\n","role":"user"}],"model":"mistral-small","stream_options":{"include_usage":true},"stream":true}'
body: '{"messages":[{"content":"You are a helpful AI assistant that generates concise, descriptive titles for conversations. You will be given up to 2 recent user messages and asked to create a single-line title that captures the main topic. Never use newlines or line breaks in your response.","role":"system"},{"content":"Based on the following recent user messages from a conversation with an AI assistant, generate a short, descriptive title (maximum 50 characters) that captures the main topic or purpose of the conversation. Return ONLY the title text on a single line, nothing else. Do not include any newlines, explanations, or formatting.\n\nRecent user messages:\n1. What''s 2+2?\n\n\n","role":"user"}],"model":"mistral-small","stream_options":{"include_usage":true},"stream":true}'
url: https://api.mistral.ai/v1/chat/completions
method: POST
response:
Expand Down
2 changes: 1 addition & 1 deletion e2e/testdata/cassettes/TestRuntime_OpenAI_Basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ interactions:
proto_minor: 1
content_length: 0
host: api.openai.com
body: '{"messages":[{"content":"You are a helpful AI assistant that generates concise, descriptive titles for conversations. You will be given a conversation history and asked to create a single-line title that captures the main topic. Never use newlines or line breaks in your response.","role":"system"},{"content":"Based on the following message a user sent to an AI assistant, generate a short, descriptive title (maximum 50 characters) that captures the main topic or purpose of the conversation. Return ONLY the title text on a single line, nothing else. Do not include any newlines, explanations, or formatting.\n\nUser message: What''s 2+2?\n\n","role":"user"}],"model":"gpt-3.5-turbo","stream_options":{"include_usage":true},"stream":true}'
body: '{"messages":[{"content":"You are a helpful AI assistant that generates concise, descriptive titles for conversations. You will be given up to 2 recent user messages and asked to create a single-line title that captures the main topic. Never use newlines or line breaks in your response.","role":"system"},{"content":"Based on the following recent user messages from a conversation with an AI assistant, generate a short, descriptive title (maximum 50 characters) that captures the main topic or purpose of the conversation. Return ONLY the title text on a single line, nothing else. Do not include any newlines, explanations, or formatting.\n\nRecent user messages:\n1. What''s 2+2?\n\n\n","role":"user"}],"model":"gpt-3.5-turbo","stream_options":{"include_usage":true},"stream":true}'
url: https://api.openai.com/v1/chat/completions
method: POST
response:
Expand Down
Loading