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
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,13 @@ ignore_missing_imports = true
module = [
"locus.rag.*",
"locus.memory.*",
"locus.loop.*",
# ``locus.hooks.builtin.*`` is held back: the module-level migration
# surfaces a real runtime bug — the LoggingHook / GuardrailsHook /
# TelemetryHook signatures pre-date the event-based ``HookProvider``
# Protocol and would TypeError when called through ``HookRegistry``.
# That is a behavioural fix, not a typing one, so it's tracked on
# its own issue and migrated in a follow-up PR.
"locus.hooks.builtin.*",
"locus.reasoning.*",
]
ignore_errors = true

Expand Down
5 changes: 4 additions & 1 deletion src/locus/loop/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ async def execute(self, state: AgentState) -> NodeResult:
from locus.tools.executor import ToolResult

tool_calls = state.last_tool_calls
events: list[ToolStartEvent | ToolCompleteEvent] = []
# ``NodeResult.events`` is invariantly typed as the broader event
# union; declare the local list with that union so the eventual
# ``return NodeResult(events=events)`` type-checks.
events: list[ThinkEvent | ToolStartEvent | ToolCompleteEvent | ReflectEvent] = []

if not tool_calls:
return NodeResult(state=state, events=[])
Expand Down
3 changes: 2 additions & 1 deletion src/locus/loop/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,10 @@ def route(self, current_node: NodeType, state: AgentState) -> RouteDecision:
try:
result = condition(state)
if result is not None:
return result.model_copy(
updated: RouteDecision = result.model_copy(
update={"metadata": {**result.metadata, "custom_condition": name}}
)
return updated
except Exception: # noqa: BLE001
# Custom condition failed, continue with others
continue
Expand Down
2 changes: 1 addition & 1 deletion src/locus/loop/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def collect(self, event: LoopEvent) -> None:
elif event.event_type == "reflect":
self.reflect_events.append(event)
elif event.event_type == "terminate":
self.terminate_event = event # type: ignore[assignment]
self.terminate_event = event

@property
def is_complete(self) -> bool:
Expand Down
3 changes: 2 additions & 1 deletion src/locus/reasoning/causal.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,8 @@ def _detect_bidirectional(self) -> list[CausalConflict]:
if not edge.is_causal:
continue

pair = tuple(sorted([edge.source_id, edge.target_id]))
ordered = sorted([edge.source_id, edge.target_id])
pair: tuple[str, str] = (ordered[0], ordered[1])
if pair in checked:
continue
checked.add(pair)
Expand Down
6 changes: 4 additions & 2 deletions src/locus/reasoning/gsar_judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

from __future__ import annotations

from typing import Any, Protocol, runtime_checkable
from typing import Any, Protocol, cast, runtime_checkable

from pydantic import BaseModel, Field, model_validator

Expand Down Expand Up @@ -317,7 +317,9 @@ async def judge(
content = response.message.content or "{}"
parsed = parse_structured(content, JudgeOutput, strict=False)
if parsed.success and parsed.parsed is not None:
return parsed.parsed
# ``parse_structured`` returns ``BaseModel | None``; the schema
# we passed in pins the dynamic type to ``JudgeOutput``.
return cast("JudgeOutput", parsed.parsed)
return safe_default_judge_output(f"judge output parse failed: {parsed.error or 'unknown'}")


Expand Down
Loading