Skip to content

Outcomes: render a table.v1 value as a Markdown table #829

Backlog

Description

@jpshackelford

Problem or use case

A table.v1 outcome value (#823, #824) is JSON. A metric card can draw it. But many places that show a factory's results cannot draw a card: an agent conversation, a Slack message, a pull request comment and an email digest. They all show Markdown.

Today each of those would have to write its own conversion from {"rows": [...]} and the key's columns to a Markdown table. They would disagree on headers, links, empty cells and escaping. An agent writes each cell, so a wrong conversion can also let one cell break the table or inject Markdown.

Desired behavior

One documented, deterministic conversion from a table.v1 value to a GitHub Flavored Markdown table. The service owns it, so every client gets the same output.

The mapping:

  • The header of a column is its title, or its name when there is no title.
  • The text of a cell is f when the cell has one, and v otherwise. A null cell is empty.
  • A cell with an href becomes [text](href). Only https:// URLs and / paths exist, because feat: add table.v1 shape for JSON outcome keys #824 refuses all others.
  • Cell text is plain text. The conversion escapes |, backslash, backticks, [, ], <, >, * and _, and turns a line break into a space. A cell cannot add columns or markup.
  • A number or integer column is right-aligned. All other columns are left-aligned.
  • When total_rows is more than the number of rows, one line follows the table: Showing <rows> of <total_rows> rows.
  • An empty table renders the header and no rows, plus the same "Showing" line if total_rows says there are more.

Example. Input (columns: pr titled "PR", status, and lines as an integer):

{"rows": [[{"v": "#818", "href": "https://github.com/OpenHands/automation/pull/818"}, "open", 412],
          [{"v": "#817", "f": "#817 (merged)"}, "merged", null]],
 "total_rows": 140}

Output:

| PR | status | lines |
| :-- | :-- | --: |
| [#818](https://github.com/OpenHands/automation/pull/818) | open | 412 |
| #817 (merged) | merged |  |

Showing 2 of 140 rows.

Acceptance criteria

  • A function turns a table.v1 value and its columns into Markdown, with the mapping above.
  • Tests cover escaping of each special character, a link cell, f over v, null cells, alignment, an empty table, total_rows larger than the rows, and a cell with a line break.
  • A test renders a table with the most columns and rows that feat: add table.v1 shape for JSON outcome keys #824 allows, and checks that every row has the same number of cells.
  • The same input always gives the same text.
  • uv run pre-commit run --all-files passes.

Additional context

  • Why the caps in feat: add table.v1 shape for JSON outcome keys #824 are small: a table has at most 8 columns and 20 rows, so its Markdown stays readable in a chat message or a comment. GitHub Flavored Markdown tables have no merged cells, no multi-line cells and no nesting, which is why table.v1 is flat. See the GFM tables extension.
  • Open question: where does the conversion run? A server route could return it, for example a format=markdown option on the read route. A shared helper could be called by the code that posts to Slack or to a pull request. Or only the client could do it. The first option gives one output for every client, but it adds an API surface. This issue does not decide. The first change can be the function alone.
  • Not part of this issue: how a card draws the table (the display layer), and the last aggregation that reads the latest table.
  • Depends on feat: add table.v1 shape for JSON outcome keys #824.

This issue was drafted by an AI agent on behalf of the user.


OpenHands AI triage

The following comments and acceptance criteria were added by the OpenHands AI agent.

Triage

The issue states the problem, the full mapping, a worked example and its own non-goals. It also answers its open question: it records that the first change is the conversion function alone, with no decision yet on where clients call it. Verified against the repository and the dependency: table.v1 is defined by #823 and implemented by open PR #824 (branch outcome-key-shapes), which fixes the caps at 8 columns and 20 rows, restricts an href to https:// URLs and / paths, and stores cells as plain values or {v, f, href} objects that round-trip unchanged. No Markdown rendering exists in the service today, and the read route returns JSON only, so the scope below is the function plus tests and nothing else.

Scope: one deterministic, documented conversion from a table.v1 value and its key's columns to a GitHub Flavored Markdown table, with the mapping exactly as the issue specifies, plus the tests listed in the issue's criteria.

Non-goals, per the issue: no format=markdown route or other API surface, no change to the read routes' JSON responses, no wiring into Slack, pull request or digest posting, no metric-card display layer, and no last aggregation. The function ships alone; callers are chosen later.

Acceptance Criteria

  • A function renders a table.v1 value and its key's columns as a GitHub Flavored Markdown table per the mapping in the issue: header is title else name; cell text is f else v else empty for null; an href cell renders as [text](href); |, backslash, backtick, [, ], <, >, * and _ are escaped and a line break becomes a space; number and integer columns are right-aligned, others left-aligned.
  • A table with 1 column and 0 rows renders the header row and delimiter only; when total_rows is present and greater than the row count (including 0 rows), the output ends with exactly Showing <rows> of <total_rows> rows.; when total_rows is absent or equals the row count, no Showing line appears.
  • Rendering the issue's example value (columns pr/status/lines integer) reproduces the example's Markdown output exactly, character for character.
  • For a cell that is a non-string scalar (for example a boolean or number), the rendered text is the stored JSON scalar form (true/false/digits), since the same text must serve every client.
  • Tests cover: each of the nine special characters escaped; a line break in a cell; a link cell; f preferred over v; null cells; alignment for number, integer and other types; an empty table; total_rows larger than the row count.
  • A test renders a table at the feat: add table.v1 shape for JSON outcome keys #824 caps (8 columns, 20 rows) and checks that every row, including the header, has the same number of cells, so an escaped cell cannot change the column count.
  • Rendering the same input twice yields identical text.
  • The function is importable and callable without an HTTP request, and no route, response schema or client wiring changes; the read route's JSON output is unchanged.
  • uv run python -m pytest passes for the new tests, and uv run pre-commit run --all-files passes.

Activity

  1. added
    enhancement
    on Nov 30, 2026
  2. added
    ready-for-dev
    on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpriority:lowready-for-dev

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions