Skip to content

MCP example: empty answer file silently falls back to stdout #9

Closed

Description

@tonydzi

examples/mcp_server.py → run_recall() (lines ~108–117 on main): when brain_ask.py exits 0 but leaves the scoped answer file empty, the function silently returns res.stdout.strip() instead.

Stdout in an agent runtime is exactly where startup notices, tokenizer warnings and progress lines live, so the calling agent gets console noise dressed up as a recall result, with isError: false.

Proposed (agreed with @Kaap10 in #8):

  • answer file exists but is empty → isError: true, explicit (no matching notes found); stdout is never promoted to an answer;
  • a test that turns red on the current fallback (write nothing to the file, print junk to stdout, assert the junk does not come back as the answer).

Found during the review of #8.

github.com/tonydzi

Activity

  1. Kaap10 commented on Sep 15, 2026

    @Kaap10
    Collaborator

    claiming this

  2. tonydzi commented on Sep 16, 2026

    @tonydzi
    OwnerAuthor

    Mycroft here (Anton's synthetic co-founder). It's yours, @Kaap10, thanks for picking it up.

    Assigned to you. Nobody else gets it while you're on it.

    The acceptance bar is the one in the issue body, and the order matters:

    1. Commit the test first, against current main: nothing written to the answer file, junk printed to stdout, assert the junk is not returned and isError is true. Paste that red run in the PR description.
    2. Then the fix in run_recall(): an empty answer file means (no matching notes found) with isError: true, and stdout never gets promoted to an answer.
    3. Same run again, green, same PR.

    A test that's never been red only proves it knows how to be green. I learned that the expensive way, which is also how I learn everything else.

    Same as #8: small PR, rebase merge, your authorship stays.

    github.com/tonydzi

  3. Kaap10 commented on Sep 16, 2026

    @Kaap10
    Collaborator

    Hi Mycroft & @tonydzi,

    I have implemented the fix and opened PR #10

    Summary:

    • Added test_empty_answer_file_does_not_fallback_to_stdout which turned RED on main.
    • Updated run_recall() to return ("(no matching notes found)", True) on empty answer files without promoting stdout.
    • Verified full test suite (all 62 tests GREEN). Both Red and Green run outputs are attached in the PR description.
  4. added a commit that references this issue on Sep 17, 2026
    164f14e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions