repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
Mirrored from https://github.com/yingqi-z20/Agent-libOS
stars
latest
clone command
git clone gitlawb://did:key:z6MkqRzA...RfoM/yingqi-z20-Agen...git clone gitlawb://did:key:z6MkqRzA.../yingqi-z20-Agen...d98dd2c9IPC1d ago| #1 | from __future__ import annotations |
| #2 | |
| #3 | import tempfile |
| #4 | import unittest |
| #5 | from pathlib import Path |
| #6 | |
| #7 | from agent_libos import Runtime |
| #8 | |
| #9 | |
| #10 | class PersistentRuntimeTests(unittest.TestCase): |
| #11 | def test_static_tool_ids_survive_runtime_reopen(self) -> None: |
| #12 | with tempfile.TemporaryDirectory() as tmp: |
| #13 | db_path = Path(tmp) / "runtime.sqlite" |
| #14 | runtime = Runtime.open(db_path) |
| #15 | try: |
| #16 | pid = runtime.process.spawn(image="review-agent:v0", goal="persistent tool table") |
| #17 | tool_id = runtime.process.get(pid).tool_table["get_current_time"] |
| #18 | self.assertTrue(runtime.tools.call(pid, "get_current_time", {}).ok) |
| #19 | finally: |
| #20 | runtime.close() |
| #21 | |
| #22 | reopened = Runtime.open(db_path) |
| #23 | try: |
| #24 | resolved = reopened.tools.resolve("get_current_time", pid=pid) |
| #25 | result = reopened.tools.call(pid, "get_current_time", {}) |
| #26 | |
| #27 | self.assertEqual(resolved.tool_id, tool_id) |
| #28 | self.assertTrue(result.ok, result.error) |
| #29 | self.assertEqual( |
| #30 | len([row for row in reopened.tools.list() if row["name"] == "get_current_time"]), |
| #31 | 1, |
| #32 | ) |
| #33 | finally: |
| #34 | reopened.close() |
| #35 | |
| #36 | |
| #37 | if __name__ == "__main__": |
| #38 | unittest.main() |
| #39 |