Skip to content

fix(reports): add extension handling to TerminalReport.generate_to_file (#83)#190

Merged
bityodha merged 1 commit into
mainfrom
fix/83-terminal-report-extension
Jul 17, 2026
Merged

fix(reports): add extension handling to TerminalReport.generate_to_file (#83)#190
bityodha merged 1 commit into
mainfrom
fix/83-terminal-report-extension

Conversation

@himanshu231204

Copy link
Copy Markdown
Member

Summary

TerminalReport.generate_to_file wrote the raw output_path with no extension logic, while every other report generator applies consistent extension handling:

  • MarkdownReport -> defaults to report.md
  • JSONReport -> defaults to report.json
  • HTMLReport -> defaults to report.html and normalizes a wrong suffix to .html
  • ComparisonReport -> defaults to comparison.txt

This inconsistency meant a call like generate_to_file(report, "my_run") produced a file named my_run with no extension, unlike the other formats. The terminal test even hard-coded report.txt, masking the gap. (issue #83)

Changes

openagent_eval/reports/terminal.pygenerate_to_file now mirrors the HTML generator's robust pattern:

path = Path(output_path)
if path.suffix == "":
    path = path / "report.txt"
elif path.suffix.lower() != ".txt":
    path = path.with_suffix(".txt")
path = self._prepare_output_file(path)

Behavior:

  • No extension -> appends report.txt
  • Wrong extension (e.g. .log) -> normalized to .txt
  • Explicit .txt -> preserved as-is

tests/unit/test_reports/test_terminal.py — added three tests covering default, normalization, and passthrough paths.

Testing

  • uv run pytest tests/unit/test_reports/ -> 98 passed
  • uv run ruff check on changed files -> clean
  • New cases: test_generate_to_file_defaults_to_txt, test_generate_to_file_normalizes_wrong_suffix, test_generate_to_file_keeps_txt_suffix

Checklist

  • Fix matches the extension-handling pattern of other generators
  • Unit tests added for success + edge (wrong suffix) paths
  • ruff passes
  • Full reports test suite passes (no regressions)
  • Branch fix/83-terminal-report-extension off main, not developed on main

TerminalReport.generate_to_file wrote the raw output path with no extension logic, while markdown, JSON, and HTML generators default to a format extension or normalize a wrong suffix. Now terminal defaults to report.txt when no extension is given and normalizes a non-.txt suffix to .txt, matching the other generators (issue #83).
@bityodha
bityodha merged commit 13a0517 into main Jul 17, 2026
10 checks passed
@github-actions

Copy link
Copy Markdown

🎉 Congratulations @himanshu231204!

Your pull request has been successfully merged into main. 🚀

Thank you for contributing to OpenAgentHQ and helping improve the project.

We truly appreciate your contribution and hope to see you back with more amazing PRs!

Happy Open Sourcing! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants