Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion agents/paradigm_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ def _build_structure_prompt(signals: dict) -> str:
continue
sections.append(f"\n## {title}")
for row in rows[:10]:
sections.append(f"- {json.dumps(row, ensure_ascii=True)[:220]}")
# Postgres rows carry datetime objects (SQLite returns strings);
# default=str keeps prompt building backend-agnostic.
sections.append(f"- {json.dumps(row, ensure_ascii=True, default=str)[:220]}")

return "\n".join(sections)

Expand Down
39 changes: 39 additions & 0 deletions tests/test_paradigm_prompt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""_build_structure_prompt must handle DB rows from both backends.

Postgres returns datetime objects in signal rows where SQLite returns
strings; prompt building must not crash on either."""

from __future__ import annotations

import os
import unittest
from datetime import datetime

os.environ["DEEPGRAPH_DATABASE_URL"] = "" # force SQLite tmpdir; never touch a real DB from the environment


class StructurePromptTest(unittest.TestCase):
def test_rows_with_datetime_values(self):
from agents.paradigm_agent import _build_structure_prompt

signals = {
"entity_overlaps": [],
"pattern_matches": [],
"contradiction_clusters": [],
"taxonomy_map": [],
"hidden_variable_bridges": [
{
"entity": "gaussian splatting",
"node_a": "cv.3d",
"node_b": "cv.sfm",
"created_at": datetime(2026, 6, 12, 12, 0, 0),
}
],
}
prompt = _build_structure_prompt(signals)
self.assertIn("gaussian splatting", prompt)
self.assertIn("2026-06-12", prompt)


if __name__ == "__main__":
unittest.main()
Loading