The world's first agentic reverse engineer.
feat: add cost_tracking field to JSON export
Amruthedac7176496d
diff --git a/kong/agent/supervisor.py b/kong/agent/supervisor.pyindex 6bd7663..274c888 100644--- a/kong/agent/supervisor.py+++ b/kong/agent/supervisor.py@@ -766,6 +766,7 @@ class Supervisor:decompilations=decompilations,token_usage=token_usage,duration_seconds=self.stats.duration_seconds,+ provider=self.config.llm.provider,)formats = self.config.output.formatsdiff --git a/kong/export/source.py b/kong/export/source.pyindex b428c87..854b291 100644--- a/kong/export/source.py+++ b/kong/export/source.py@@ -4,6 +4,7 @@ from dataclasses import dataclassfrom pathlib import Pathfrom typing import TYPE_CHECKING+from kong.config import LLMProviderfrom kong.ghidra.types import BinaryInfofrom kong.llm.usage import TokenUsage@@ -37,6 +38,7 @@ class ExportData:decompilations: dict[int, str]token_usage: TokenUsageduration_seconds: float+ provider: LLMProvider | None = Nonedef _format_header(data: ExportData) -> str:diff --git a/kong/export/structured.py b/kong/export/structured.pyindex a31114c..25e912e 100644--- a/kong/export/structured.py+++ b/kong/export/structured.py@@ -4,6 +4,7 @@ import jsonfrom pathlib import Pathfrom kong.agent.models import FunctionResult+from kong.config import LLMProviderfrom kong.export.source import ExportData@@ -20,8 +21,9 @@ def _build_binary_section(data: ExportData) -> dict[str, str | int]:}-def _build_stats_section(data: ExportData) -> dict[str, int | float]:+def _build_stats_section(data: ExportData) -> dict[str, int | float | bool]:s = data.stats+ cost_tracking = data.provider is not LLMProvider.CUSTOM if data.provider else Truereturn {"total_functions": s.total_functions,"analyzed": s.analyzed,@@ -36,6 +38,7 @@ def _build_stats_section(data: ExportData) -> dict[str, int | float]:"llm_calls": s.llm_calls,"duration_seconds": data.duration_seconds,"cost_usd": data.token_usage.total_cost_usd,+ "cost_tracking": cost_tracking,}diff --git a/tests/test_export_structured.py b/tests/test_export_structured.pyindex dd00d9a..f35f4df 100644--- a/tests/test_export_structured.py+++ b/tests/test_export_structured.py@@ -5,8 +5,8 @@ from pathlib import Pathimport pytest-from kong.agent.models import FunctionResult-from kong.agent.models import AnalysisStats+from kong.agent.models import AnalysisStats, FunctionResult+from kong.config import LLMProviderfrom kong.export.source import ExportDatafrom kong.export.structured import export_jsonfrom kong.ghidra.types import BinaryInfo@@ -262,3 +262,20 @@ def test_functions_sorted_by_address(parsed = _export_and_load(data, tmp_path)addresses = [f["address"] for f in parsed["functions"]]assert addresses == ["0x00001000", "0x00003000", "0x00005000"]+++class TestCostTrackingField:+ def test_json_export_includes_cost_tracking_true(+ self, tmp_path, binary_info, stats, token_usage, sample_results,+ ):+ data = _make_data(binary_info, stats, token_usage, sample_results)+ parsed = _export_and_load(data, tmp_path)+ assert parsed["stats"]["cost_tracking"] is True++ def test_json_export_cost_tracking_false_for_custom(+ self, tmp_path, binary_info, stats, token_usage, sample_results,+ ):+ data = _make_data(binary_info, stats, token_usage, sample_results)+ data.provider = LLMProvider.CUSTOM+ parsed = _export_and_load(data, tmp_path)+ assert parsed["stats"]["cost_tracking"] is False