Skip to content

[Bug]: agent-context Bash port aborts as "malformed" when config markers are blank, instead of using defaults #3735

Description

@matecardoso

What happened

In the agent-context extension's Bash port (extensions/agent-context/scripts/bash/update-agent-context.sh), when the config omits context_markers (or sets them blank) to rely on the built-in defaults, the script aborts:

agent-context: malformed config parser output; expected 3 lines (context_files, marker_start, marker_end), got 1; skipping update.

and the context file is never updated. The Python and PowerShell ports handle the same config correctly.

Root cause

The config parser prints three lines — context_files JSON, context_markers.start, context_markers.end — captured via _raw_opts="$(...)". Command substitution strips trailing newlines, so when the marker lines are empty (blank/omitted markers), the output collapses to fewer than three lines. The guard then fires:

if (( ${#_opts_lines[@]} < 3 )); then ... exit 0 ; fi

which makes the default-marker substitution below unreachable in exactly the case it exists for:

[[ -z "$MARKER_START" ]] && MARKER_START="$DEFAULT_START"
[[ -z "$MARKER_END"   ]] && MARKER_END="$DEFAULT_END"

The Python port applies ... or DEFAULT_START, and PowerShell initializes to defaults, so both succeed — the three ports diverge across platforms.

Expected

With blank/omitted markers, the Bash port uses DEFAULT_START/DEFAULT_END and updates the context file, matching the Python/PowerShell ports.

Fix

Require only the mandatory context_files line and default the marker lines to empty (${_opts_lines[1]:-} / ${_opts_lines[2]:-}) so the existing default substitution runs. PR incoming with a parity regression test.

Version

Reproduced on main (0.14.2 / 0.14.3.dev0).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions