agent: /cost command shows last-turn and session cost

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Levi Neely 2026-04-27 18:45:57 +02:00
parent f16ba70126
commit efb75ddea0
2 changed files with 11 additions and 1 deletions

View File

@ -246,6 +246,15 @@ func (s *agent) handleCommand(ctx context.Context, input string, handler EventHa
handler(infoEvent(strings.TrimRight(s.session.contextDebug(), "\n")))
},
"/cost": func(args []string) {
if s.session == nil {
handler(infoEvent("no active session"))
return
}
handler(infoEvent(fmt.Sprintf("last=$%.4f session=$%.4f",
s.session.LastTurnCostUSD, s.session.SessionCostUSD)))
},
"/usage": func(args []string) {
if s.session == nil {
handler(infoEvent("no active session"))
@ -369,6 +378,7 @@ func (s *agent) handleCommand(ctx context.Context, input string, handler EventHa
" /queued [pop|clear] - manage queued prompts",
" /compact - summarize conversation and compact context",
" /context - show context size and message breakdown",
" /cost - show last turn and session cost",
" /usage - show token usage and context percentage",
" /history - dump bounded message history",
" /clear - clear session",

View File

@ -373,7 +373,7 @@ func (h *sessionHelper) handleCtl(input string) error {
return h.saveTranscript(data)
case "compact", "clear", "backend", "model", "models",
"agents", "agent", "sessions", "cwd", "skills",
"tools", "context", "usage", "history",
"tools", "context", "usage", "cost", "history",
"irw", "help":
h.sess.Core.Submit(h.sess.Ctx, "/"+input, h.makePublish())
default: