Skip to content

Console launcher: CJK characters cannot be deleted during input editing #978

@bitsark

Description

@bitsark

Description

When using the console launcher (cmd/launcher/console), editing Chinese/CJK characters during input doesn't work correctly. Specifically, after typing Chinese characters, pressing Backspace fails to delete them. ASCII/English characters work fine.

Steps to Reproduce

Build and run any agent with the console launcher
Type Chinese characters (e.g. via an IME) at the User -> prompt
Press Backspace to try to delete the Chinese characters
Observe that the characters cannot be deleted, or only partially deleted

Root Cause

The console launcher reads input via bufio.NewReader(os.Stdin).ReadString('\n') (console.go:120-127):

go func() {
    reader := bufio.NewReader(os.Stdin)
    for {
        userInput, err := reader.ReadString('\n')
        if err != nil {
            readErrChan <- err
            return
        }
        inputChan <- userInput
    }
}()

bufio.Reader has an internal 4096-byte read buffer that eagerly consumes bytes from stdin. CJK characters are UTF-8 multi-byte (3 bytes per character) and occupy 2 terminal columns (wide characters). When an IME sends intermediate composition bytes to stdin, the bufio.Reader may consume them into its buffer, causing the terminal's input editing state to desync from what the program has read. This makes Backspace unable to correctly delete the characters.

Suggested Fix

Replace the raw bufio.Reader with a proper readline library (e.g. github.com/ergochat/readline) that correctly handles:

UTF-8 multi-byte character width and cursor movement
IME composition state
Line editing operations (backspace, delete, cursor movement)

Environment

adk-go v1.4.0
macOS Darwin 25.5.0
Terminal: VS Code integrated terminal / iTerm2
Input method: macOS Chinese IME

Metadata

Metadata

Labels

bugSomething isn't working

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions