Skip to content

Commit bb37aa8

Browse files
committed
style: satisfy staging Ruff checks for v1.4.5
Signed-off-by: ahmad-ajmal <ahmadajmal1514@gmail.com>
1 parent 3b9b1ca commit bb37aa8

88 files changed

Lines changed: 6384 additions & 1524 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎agent_core/core/impl/action/executor.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ class _HiddenEnvBuilder(venv.EnvBuilder):
6161
"""Keep ensurepip's interpreter and installer children hidden too."""
6262

6363
def _call_new_python(self, context, *args, **kwargs):
64-
return super()._call_new_python(context, *args, **kwargs, **hidden_console_kwargs())
64+
return super()._call_new_python(
65+
context, *args, **kwargs, **hidden_console_kwargs()
66+
)
6567

6668

6769
def _get_persistent_venv_dir() -> Path:

‎agent_core/core/impl/action/reply_stream.py‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,9 @@ def _close_string(self, i: int) -> None:
255255
self.reasoning_end = i
256256
elif self._str_role == "status":
257257
try:
258-
self.status = status_line(json.loads(self.text[self._str_start : i + 1]))
258+
self.status = status_line(
259+
json.loads(self.text[self._str_start : i + 1])
260+
)
259261
except ValueError:
260262
self.status = None
261263
self._str_role = None
@@ -274,7 +276,9 @@ def reasoning(self) -> Optional[str]:
274276
return self._reasoning
275277
if self.reasoning_end is not None:
276278
try:
277-
value = json.loads(self.text[self.reasoning_start : self.reasoning_end + 1])
279+
value = json.loads(
280+
self.text[self.reasoning_start : self.reasoning_end + 1]
281+
)
278282
except ValueError:
279283
value = None
280284
self._reasoning = value if isinstance(value, str) else ""
@@ -538,9 +542,7 @@ def finish(self, decisions: List[Dict[str, Any]]) -> None:
538542
none) is what the chat shows while they run, also when the reply did
539543
not stream."""
540544
keep = [
541-
d["_run_id"]
542-
for d in decisions
543-
if d.get("_run_id") and not d.get("_error")
545+
d["_run_id"] for d in decisions if d.get("_run_id") and not d.get("_error")
544546
]
545547
self._end(keep, status=decisions[0].get("status") if decisions else None)
546548

‎agent_core/core/impl/action/router.py‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -808,12 +808,14 @@ def full_request(up_to: Optional[int]) -> str:
808808
# No session registered (simple task) - use prefix cache / regular response
809809
sent_prompt = full_request(point)
810810
with streaming_to(reply_sink):
811-
raw_response = await self.llm_interface.generate_response_async(
812-
system_prompt,
813-
sent_prompt,
814-
prompt_name=prompt_name,
815-
usage_key=f"{current_task_id}:{call_type}",
816-
call_metadata={"request": "stateless"},
811+
raw_response = (
812+
await self.llm_interface.generate_response_async(
813+
system_prompt,
814+
sent_prompt,
815+
prompt_name=prompt_name,
816+
usage_key=f"{current_task_id}:{call_type}",
817+
call_metadata={"request": "stateless"},
818+
)
817819
)
818820
# The prompt carried the stream's first ``point``
819821
# events; a later fold may collapse any of them now.
@@ -1046,9 +1048,7 @@ def _parse_action_decision(
10461048
# the decision, so take it instead of spending a retry.
10471049
parsed = _first_json_object(normalized)
10481050
if parsed is None:
1049-
logger.error(
1050-
f"Unable to parse action decision: {repr(normalized)}"
1051-
)
1051+
logger.error(f"Unable to parse action decision: {repr(normalized)}")
10521052
return (
10531053
None,
10541054
f"json error: {json_error}; literal_eval error: {eval_error}",

‎agent_core/core/impl/action/step.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ async def decide(
4848

4949
reasoning = decisions[0].get("reasoning", "")
5050
logger.debug(f"[AGENT REASONING] {reasoning}")
51-
if reasoning and not (reply_stream is not None and reply_stream.reasoning_logged):
51+
if reasoning and not (
52+
reply_stream is not None and reply_stream.reasoning_logged
53+
):
5254
self.log_reasoning(
5355
session_id,
5456
reasoning,

‎agent_core/core/impl/session/manager.py‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,9 @@ def mark_framework_creation(self, session_id: str, title: str) -> Session:
319319
self._persist(session)
320320
return session
321321

322-
def bind_framework_app(self, session_id: str, key: str, *, previous_key: str | None = None) -> Session:
322+
def bind_framework_app(
323+
self, session_id: str, key: str, *, previous_key: str | None = None
324+
) -> Session:
323325
"""Give an app's existing conversation its dedicated type, keeping history.
324326
325327
Main, legacy app sessions and delegated task sessions cannot be adopted.
@@ -490,7 +492,11 @@ def _compile_actions(session: Session) -> None:
490492
"send_message",
491493
"end_turn",
492494
]
493-
session.compiled_actions.extend(name for name in session.app_task_actions if name not in session.compiled_actions)
495+
session.compiled_actions.extend(
496+
name
497+
for name in session.app_task_actions
498+
if name not in session.compiled_actions
499+
)
494500

495501
def add_skill(self, session_id: str, skill_name: str) -> bool:
496502
"""Load a skill into a session (additive).

‎agent_core/core/impl/skill/manager.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ async def _discover_skills(self) -> None:
8484
# Once the framework is available, its skills replace these removed
8585
# CraftBot workflows; keep the old files intact but out of discovery.
8686
if self._bundled_sources and skill.name in {
87-
"agent-app-creator", "agent-app-importer",
88-
"agent-app-manager", "agent-app-modify",
87+
"agent-app-creator",
88+
"agent-app-importer",
89+
"agent-app-manager",
90+
"agent-app-modify",
8991
}:
9092
continue
9193
self._skills[skill.name] = skill
@@ -98,7 +100,8 @@ async def _discover_skills(self) -> None:
98100
# CraftBot bindings only: the upstream skill files stay immutable.
99101
skill.metadata.action_sets = (
100102
["a2app"]
101-
if name in {"framework-operator", "framework-connect", "framework-walk-verify"}
103+
if name
104+
in {"framework-operator", "framework-connect", "framework-walk-verify"}
102105
else ["agent_app", "a2app"]
103106
)
104107
skill.instructions = f"Source: {source}\nResolve relative references from {source.parent}.\n\n{skill.instructions}"

‎agent_core/core/llm/google_gemini_client.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,11 @@ def _post_stream(self, path: str, payload: Dict[str, Any], sink) -> Dict[str, An
938938
parts[-1] = {"text": parts[-1]["text"] + text}
939939
else:
940940
parts.append(dict(part))
941-
if index == 0 and isinstance(text, str) and not part.get("thought"):
941+
if (
942+
index == 0
943+
and isinstance(text, str)
944+
and not part.get("thought")
945+
):
942946
emit(sink, text)
943947
finally:
944948
response.close()

‎agent_core/core/prompts/obsolete.py‎

Lines changed: 82 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -439,88 +439,88 @@
439439

440440

441441
def v0_capability_catalog() -> str:
442-
"""Create the Capability Catalog system block.
443-
444-
Lists every available action set and every enabled skill with a
445-
one-line description, so any session can discover and load
446-
capabilities on demand (add_action_sets / use_skill). The catalog
447-
is stable per boot, so it lives in the cached system prefix.
448-
"""
449-
lines = ["<capability_catalog>"]
450-
451-
try:
452-
from app.action.action_set import action_set_manager
453-
454-
sets_text = _v0_format_sets(action_set_manager, exclude_core=True)
455-
lines.append(
456-
"Action sets you can load with 'add_action_sets' "
457-
"(your session always has 'core'):"
458-
)
459-
lines.append(sets_text if sets_text else "(no additional action sets)")
460-
except Exception as e:
461-
_logger.debug(f"[CONTEXT] Capability catalog: action sets failed: {e}")
462-
463-
try:
464-
from app.skill import skill_manager
465-
466-
skills = skill_manager.list_skills_for_selection()
467-
lines.append("")
468-
lines.append("Skills you can load with 'use_skill':")
469-
if skills:
470-
lines.extend(f"- {name}: {desc}" for name, desc in skills.items())
471-
else:
472-
lines.append("(no skills available)")
473-
except Exception as e:
474-
_logger.debug(f"[CONTEXT] Capability catalog: skills failed: {e}")
475-
476-
lines.append("</capability_catalog>")
477-
return "\n".join(lines)
442+
"""Create the Capability Catalog system block.
443+
444+
Lists every available action set and every enabled skill with a
445+
one-line description, so any session can discover and load
446+
capabilities on demand (add_action_sets / use_skill). The catalog
447+
is stable per boot, so it lives in the cached system prefix.
448+
"""
449+
lines = ["<capability_catalog>"]
450+
451+
try:
452+
from app.action.action_set import action_set_manager
453+
454+
sets_text = _v0_format_sets(action_set_manager, exclude_core=True)
455+
lines.append(
456+
"Action sets you can load with 'add_action_sets' "
457+
"(your session always has 'core'):"
458+
)
459+
lines.append(sets_text if sets_text else "(no additional action sets)")
460+
except Exception as e:
461+
_logger.debug(f"[CONTEXT] Capability catalog: action sets failed: {e}")
462+
463+
try:
464+
from app.skill import skill_manager
465+
466+
skills = skill_manager.list_skills_for_selection()
467+
lines.append("")
468+
lines.append("Skills you can load with 'use_skill':")
469+
if skills:
470+
lines.extend(f"- {name}: {desc}" for name, desc in skills.items())
471+
else:
472+
lines.append("(no skills available)")
473+
except Exception as e:
474+
_logger.debug(f"[CONTEXT] Capability catalog: skills failed: {e}")
475+
476+
lines.append("</capability_catalog>")
477+
return "\n".join(lines)
478478

479479

480480
def _v0_format_sets(manager, exclude_core: bool = False) -> str:
481-
"""
482-
Format action set information for inclusion in prompts.
483-
484-
Args:
485-
exclude_core: If True, don't include core set (it's always auto-included)
486-
487-
Returns:
488-
Formatted string describing available action sets: one line per
489-
set, then one line per integration naming all of its sets
490-
(described once, by the integration's provider). Sorted, so the
491-
catalog (part of the cached system prompt) renders the same on
492-
every boot.
493-
"""
494-
all_sets = manager.list_all_sets()
495-
integrations = {
496-
integration: [s for s in sets if s in all_sets]
497-
for integration, sets in manager.integration_sets().items()
498-
}
499-
owned = {s for sets in integrations.values() for s in sets}
500-
501-
lines = []
502-
for set_name, description in sorted(all_sets.items()):
503-
if set_name in owned or (exclude_core and set_name == "core"):
504-
continue
505-
if set_name == "core":
506-
lines.append(f"- {set_name}: {description} (always included)")
507-
else:
508-
lines.append(f"- {set_name}: {description}")
509-
510-
rows = []
511-
for integration, sets in integrations.items():
512-
if not sets:
513-
continue
514-
name, what = manager.integration_description(integration)
515-
# The set named after the integration first: its high-value actions.
516-
ordered = sorted(sets, key=lambda s: (s != integration, s))
517-
label = f"{name} ({what})" if what else name
518-
rows.append((name.lower(), f"- {label}: {', '.join(ordered)}"))
519-
if rows:
520-
lines.append(
521-
"Integration action sets. Load the set named after an "
522-
"integration for its high-value actions; load a narrower set "
523-
"when the task needs a specific area:"
524-
)
525-
lines.extend(row for _, row in sorted(rows))
526-
return "\n".join(lines)
481+
"""
482+
Format action set information for inclusion in prompts.
483+
484+
Args:
485+
exclude_core: If True, don't include core set (it's always auto-included)
486+
487+
Returns:
488+
Formatted string describing available action sets: one line per
489+
set, then one line per integration naming all of its sets
490+
(described once, by the integration's provider). Sorted, so the
491+
catalog (part of the cached system prompt) renders the same on
492+
every boot.
493+
"""
494+
all_sets = manager.list_all_sets()
495+
integrations = {
496+
integration: [s for s in sets if s in all_sets]
497+
for integration, sets in manager.integration_sets().items()
498+
}
499+
owned = {s for sets in integrations.values() for s in sets}
500+
501+
lines = []
502+
for set_name, description in sorted(all_sets.items()):
503+
if set_name in owned or (exclude_core and set_name == "core"):
504+
continue
505+
if set_name == "core":
506+
lines.append(f"- {set_name}: {description} (always included)")
507+
else:
508+
lines.append(f"- {set_name}: {description}")
509+
510+
rows = []
511+
for integration, sets in integrations.items():
512+
if not sets:
513+
continue
514+
name, what = manager.integration_description(integration)
515+
# The set named after the integration first: its high-value actions.
516+
ordered = sorted(sets, key=lambda s: (s != integration, s))
517+
label = f"{name} ({what})" if what else name
518+
rows.append((name.lower(), f"- {label}: {', '.join(ordered)}"))
519+
if rows:
520+
lines.append(
521+
"Integration action sets. Load the set named after an "
522+
"integration for its high-value actions; load a narrower set "
523+
"when the task needs a specific area:"
524+
)
525+
lines.extend(row for _, row in sorted(rows))
526+
return "\n".join(lines)

‎agent_core/core/session/session.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,11 @@ def from_dict(cls, data: Dict[str, Any]) -> "Session":
207207
agent_app_framework_key=data.get("agent_app_framework_key"),
208208
agent_app_framework_pending=data.get("agent_app_framework_pending", False),
209209
isolated_app_task=data.get("isolated_app_task") is True,
210-
app_task_actions=[name for name in data.get("app_task_actions", []) if isinstance(name, str)],
210+
app_task_actions=[
211+
name
212+
for name in data.get("app_task_actions", [])
213+
if isinstance(name, str)
214+
],
211215
gui_mode=data.get("gui_mode", False),
212216
reasoning_effort=_stored_reasoning_effort(data.get("reasoning_effort")),
213217
action_count=data.get("action_count", 0),

‎app/agent_app/broadcast.py‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,20 @@ def make_todo_broadcast_hook(callback):
88
loop = asyncio.get_running_loop()
99

1010
def hook(session, todos):
11-
if (session.agent_app_framework_pending or session.agent_app_framework_key) and loop.is_running():
12-
asyncio.run_coroutine_threadsafe(callback({
13-
"type": "agent_app_todos",
14-
"data": {"projectId": f"framework-build:{session.id}", "todos": todos},
15-
}), loop)
11+
if (
12+
session.agent_app_framework_pending or session.agent_app_framework_key
13+
) and loop.is_running():
14+
asyncio.run_coroutine_threadsafe(
15+
callback(
16+
{
17+
"type": "agent_app_todos",
18+
"data": {
19+
"projectId": f"framework-build:{session.id}",
20+
"todos": todos,
21+
},
22+
}
23+
),
24+
loop,
25+
)
1626

1727
return hook

0 commit comments

Comments
 (0)