Support tab (agents:support on a range with a question, instructions/support.md, its answer in labeling/auto/support/); the weather read from data/<STATION>/weather/ (pumped), no call to MeteoSwiss from the app; plots in mm (corr_x_mm, corr_y_mm); analyst instructions: the weather pumped, the targets in mm and their distance

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maximeandClaude Opus 5.5 committed 2026-11-18 07:17:51 +01:00
1 parent 60d10a282c
commit 161fb0212f
12 files changed
+414 -104

No files matched your search

+70 -1
View File
@@ -46,6 +46,8 @@ def check_server():
assert call("/api/labels", {"station": "x"}, {"Content-Type": "text/plain"}) == 403
assert call("/api/stations") == 200
assert call("/api/analyses") == 200
assert call("/api/support") == 200
assert call("/api/support", {"station": "x"}) == 400
assert call("/api/analyses/UNKNOWN/optimize", {}) == 400
finally:
srv.should_exit = True
@@ -308,7 +310,74 @@ def check_validation():
analysis.analyses.clear()
CHECKS = [check_server, check_station, check_optimization, check_analysis, check_validation]
def check_support():
# "Ask the support" then a message (support.launch, support.message), without claude: the support of the agents
# repository, its request (the question, its instructions, its absolute folder), the long commands it is given, the
# resumption of its session, its answer in the page; the state read again after a restart
import analysis
import support
launched = []
class FakeProcess:
returncode = 0
def __init__(self, args, *a, **k):
launched.append((args, k))
self.stdout = iter(['{"type":"system","subtype":"init","session_id":"s-1"}\n'])
def wait(self):
return 0
root = temp_folder()
before = support.FOLDER, analysis.subprocess.Popen, analysis.AGENTS
support.FOLDER, analysis.AGENTS, analysis.subprocess.Popen = root / "support", root / "agents", FakeProcess
key = os.environ.get("ANTHROPIC_API_KEY")
os.environ["ANTHROPIC_API_KEY"] = "test-key"
ask = {"station": "NORDEND", "start": "2026-11-05T06:00Z", "end": "2026-11-05T12:00Z", "question": "Why the jump?"}
try:
assert "agents/" in refuses(support.launch, ask)
(analysis.AGENTS / "agents").mkdir(parents=True)
(analysis.AGENTS / "agents" / "support.md").write_text("support")
assert "question" in refuses(support.launch, ask | {"question": " "})
name = support.launch(ask)["name"]
while support.supports[name]["state"] == "running":
time.sleep(0.05)
assert support.state(name)["state"] == "done" and support.state(name)["report"] is None, support.state(name)
args, k = launched[0]
assert args[args.index("--agent") + 1] == "agents:support" and "Edit" in args[args.index("--allowedTools") + 1], args
assert "ANTHROPIC_API_KEY" not in k["env"] and k["env"]["BASH_MAX_TIMEOUT_MS"] == "10800000", sorted(k["env"])
out = support.FOLDER / name
assert f"Output folder: {out}/." in args[2] and f"INSTRUCTIONS: {support.INSTRUCTIONS}." in args[2] \
and args[2].endswith("Question: Why the jump?") and support.INSTRUCTIONS.is_file(), args[2]
assert (out / "work" / "session").read_text() == "s-1"
assert support.launch(ask)["name"].startswith(name + "_") # another question on the same range, next to it
(out / "answer.md").write_text("# NORDEND: a jump\n\n![curves](fig.png)")
(out / "fig.png").write_bytes(b"png")
assert support.state(name)["report"] and "<h1>NORDEND: a jump</h1>" in support.answer(name, False)
assert analysis.file(name, "fig.png", support.FOLDER).is_file()
refuses(analysis.file, name, "../../agents/agents/support.md", support.FOLDER)
while any(s["state"] == "running" for s in support.supports.values()):
time.sleep(0.05)
support.message(name, {"text": "And the night before?"})
while support.supports[name]["state"] == "running":
time.sleep(0.05)
args = launched[-1][0]
assert args[args.index("--resume") + 1] == "s-1" and args[2].startswith("And the night before?"), args
support.supports.clear() # after a restart: the thread read again in the log, done with its answer
s = support.state(name)
assert s["state"] == "done" and s["lines"] == ["› And the night before?"], s
assert {x["name"]: x["state"] for x in support.list_supports()}[name] == "done" # the sidebar
refuses(support.state, "../analyses")
finally:
os.environ.pop("ANTHROPIC_API_KEY")
if key is not None:
os.environ["ANTHROPIC_API_KEY"] = key
shutil.rmtree(root)
support.FOLDER, analysis.subprocess.Popen, analysis.AGENTS = before
support.supports.clear()
CHECKS = [check_server, check_station, check_optimization, check_analysis, check_validation, check_support]
if __name__ == "__main__":
name = sys.argv[1] if len(sys.argv) > 1 else None