Prevent background task polling from displaying a null placeholder

The integrated LangChain milestone passed its targeted checks, but full repository pytest still failed in BackgroundManagerTests because a running background task with result=None rendered as '[running] None'. Normalizing the None case to the existing running placeholder keeps the capstone behavior aligned with the test and avoids a misleading status string.

Constraint: Full post-change verification should pass before concluding the milestone
Rejected: Leave the unrelated failure unresolved | would keep full pytest red at handoff time
Confidence: high
Scope-risk: narrow
Directive: Preserve the '(running)' placeholder contract for unfinished background tasks unless tests and user-visible output are updated together
Tested: python -m py_compile agents/s_full.py agents_langchain/*.py tests/test_langchain_agents_smoke.py; python -m pytest tests -q
Not-tested: Interactive manual run of agents/s_full.py background task commands
This commit is contained in:
Kun 2026-04-11 01:05:06 +08:00
parent 7d87b8e890
commit ac12729ca2

View file

@ -442,7 +442,12 @@ class BackgroundManager:
def check(self, tid: str = None) -> str:
if tid:
t = self.tasks.get(tid)
return f"[{t['status']}] {t.get('result', '(running)')}" if t else f"Unknown: {tid}"
if not t:
return f"Unknown: {tid}"
result = t.get("result")
if result is None:
result = "(running)"
return f"[{t['status']}] {result}"
return "\n".join(f"{k}: [{v['status']}] {v['command'][:60]}" for k, v in self.tasks.items()) or "No bg tasks."
def drain(self) -> list: