Skip to content

LCORE-1841: Demo deck: LCORE weak points for AI-driven agentic flow#1586

Merged
tisnik merged 4 commits into
lightspeed-core:mainfrom
tisnik:lcore-1841-demo
Apr 26, 2026
Merged

LCORE-1841: Demo deck: LCORE weak points for AI-driven agentic flow#1586
tisnik merged 4 commits into
lightspeed-core:mainfrom
tisnik:lcore-1841-demo

Conversation

@tisnik
Copy link
Copy Markdown
Contributor

@tisnik tisnik commented Apr 26, 2026

Description

LCORE-1841: Demo deck: LCORE weak points for AI-driven agentic flow

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement
  • Benchmarks improvement
  • Other

Tools used to create PR

  • Assisted-by: N/A
  • Generated by: N/A

Related Tickets & Documents

  • Related Issue #LCORE-1841

Summary by CodeRabbit

  • Documentation

    • Added new demo documentation page analyzing LCORE weak points in AI-driven agentic flow systems, featuring code examples and architectural insights covering consistency, concurrency, type handling, and best practices.
  • Chores

    • Updated CI/CD lint workflows to focus code quality checks on source and test directories.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 26, 2026

Warning

Rate limit exceeded

@tisnik has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 49 minutes and 53 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 49 minutes and 53 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6ede64f9-b2dd-4a4f-9cd6-196ab0add34d

📥 Commits

Reviewing files that changed from the base of the PR and between a03af18 and 1864c2e.

📒 Files selected for processing (1)
  • docs/demos/lcore/weak_points_for_ai.md

Walkthrough

CI/CD workflows and Makefile were updated to narrow linting scope from the entire repository to only the src and tests directories. New documentation demo added covering LCORE weak points for AI-driven agentic flows, including seven illustrative Python code examples demonstrating identified patterns.

Changes

Cohort / File(s) Summary
CI/CD Workflow Scope Narrowing
.github/workflows/black.yaml, .github/workflows/pydocstyle.yaml, .github/workflows/ruff.yaml, Makefile
Updated Black, Pydocstyle, Ruff, and Makefile lint targets to check only src and tests directories instead of entire repository.
Documentation Index Updates
docs/README.md, docs/index.md
Added links to new "LCORE weak points for AI-driven agentic flow" demo page in documentation and homepage.
Demo Presentation Setup
docs/demos/lcore/weak_points_for_ai.html
New Reveal.js presentation HTML file that loads Reveal plugins for notes, markdown, and syntax highlighting, with slide content sourced from markdown file.
Demo Content
docs/demos/lcore/weak_points_for_ai.md
Comprehensive markdown documentation detailing LCORE's role in AI-driven agentic flows and enumerating weak points: consistency risks, entanglement, excessive transformations, runtime type checks, and magic numbers. Includes discussion of system structure, static vs dynamic design, and recommendations for consistency and concurrency.
Code Examples
docs/demos/lcore/weak_points_for_ai/ex1.py, ex2.py, ex3.py, ex4.py, ex5.py, ex6.py, ex7.py
Seven illustrative Python code examples demonstrating identified weak patterns: predicate validation, untyped content extraction, conditional state handling, response payloads with derived values, LLM-driven tool filtering with MCP support, inline validation logic, and request mutation with redaction.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title directly and specifically describes the main change: adding a demo deck about LCORE weak points for AI-driven agentic flows, with the ticket identifier for reference.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@tisnik tisnik changed the title LCORE-1841: Examples of bad code LCORE-1841: Demo deck: LCORE weak points for AI-driven agentic flow Apr 26, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/pydocstyle.yaml:
- Line 20: The CI pydocstyle invocation checks both src and tests but the
Makefile docstyle target only checks src, causing local `make verify` to miss
test docstring issues; update the Makefile target named "docstyle" so its
pydocstyle invocation matches the workflow (run pydocstyle -v src tests) —
locate the docstyle target in the Makefile and add "tests" to the paths checked
(or unify both CI and Makefile to use the same path list).

In @.github/workflows/ruff.yaml:
- Line 20: Remove the redundant per-file-ignores flag from the ruff invocation:
the command "uv tool run ruff check src tests --per-file-ignores=tests/*:S101
--per-file-ignores=scripts/*:S101" should be simplified to omit
"--per-file-ignores=scripts/*:S101" since ruff is only checking "src" and
"tests"; keep the tests ignore only.

In `@docs/demos/lcore/weak_points_for_ai.html`:
- Line 2: Add a lang attribute to the root HTML element (the <html> tag) to
provide a language hint for screen readers and validators; update the <html> tag
in docs/demos/lcore/weak_points_for_ai.html (the root <html> element) to include
an appropriate language code (for example lang="en" or the correct locale for
the document) and ensure any related tooling or templates that generate this
file also propagate that attribute.

In `@docs/demos/lcore/weak_points_for_ai.md`:
- Around line 17-21: Fix three small text issues in the slide content: change
"It allow developers" to "It allows developers" in the first bullet, change
"LLMS" to "LLMs" in the "Context-awareness problem" bullet (to match deck
usage), and on the separate slide replace "An interesting are to research" with
"An interesting area to research"; update those exact phrases in the markdown so
rendering and consistency are corrected.
- Around line 264-306: Remove the stray closing parenthesis after the loop in
the _filter_tools_for_response snippet (the lone ')' following
result.append(tool)) which causes a syntax error; delete that extraneous
character so the function returns result properly and ensure indentation of the
return result line remains aligned with the if filtered_tool_names: block.

In `@docs/demos/lcore/weak_points_for_ai/ex5.py`:
- Around line 144-148: The snippet has a stray closing parenthesis after
result.append(tool) causing a SyntaxError; remove the extraneous ')' so the loop
appends correctly (look for the result.append(tool) statement inside the
function that builds and returns result) and ensure the function returns result
or [] as intended.

In `@Makefile`:
- Line 102: Makefile targets use inconsistent lint scopes and the verify target
is missing linters; update the black, ruff, docstyle, and format targets to use
the same scope as CI (src tests) instead of . or only src, and modify or add the
verify target so it invokes all linters (black, ruff, docstyle, pylint, pyright)
— reference the Makefile targets named format, black, ruff, docstyle, and verify
to locate and change their commands so local checks match CI and include the
missing linters.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8311f70d-efe2-4f57-ac81-a731d177f0a9

📥 Commits

Reviewing files that changed from the base of the PR and between b05567b and a03af18.

📒 Files selected for processing (15)
  • .github/workflows/black.yaml
  • .github/workflows/pydocstyle.yaml
  • .github/workflows/ruff.yaml
  • Makefile
  • docs/README.md
  • docs/demos/lcore/weak_points_for_ai.html
  • docs/demos/lcore/weak_points_for_ai.md
  • docs/demos/lcore/weak_points_for_ai/ex1.py
  • docs/demos/lcore/weak_points_for_ai/ex2.py
  • docs/demos/lcore/weak_points_for_ai/ex3.py
  • docs/demos/lcore/weak_points_for_ai/ex4.py
  • docs/demos/lcore/weak_points_for_ai/ex5.py
  • docs/demos/lcore/weak_points_for_ai/ex6.py
  • docs/demos/lcore/weak_points_for_ai/ex7.py
  • docs/index.md
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
  • GitHub Check: bandit
  • GitHub Check: pydocstyle
  • GitHub Check: Pyright
  • GitHub Check: radon
  • GitHub Check: unit_tests (3.13)
  • GitHub Check: build-pr
  • GitHub Check: Pylinter
  • GitHub Check: unit_tests (3.12)
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-on-pull-request
  • GitHub Check: E2E: server mode / ci / group 3
  • GitHub Check: E2E: library mode / ci / group 2
  • GitHub Check: E2E: library mode / ci / group 1
  • GitHub Check: E2E: server mode / ci / group 1
  • GitHub Check: E2E: server mode / ci / group 2
  • GitHub Check: E2E: library mode / ci / group 3
  • GitHub Check: E2E Tests for Lightspeed Evaluation job
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Use absolute imports for internal modules: from authentication import get_auth_dependency
Import FastAPI dependencies with: from fastapi import APIRouter, HTTPException, Request, status, Depends
Import Llama Stack client with: from llama_stack_client import AsyncLlamaStackClient
Check constants.py for shared constants before defining new ones
All modules start with descriptive docstrings explaining purpose
Use logger = get_logger(__name__) from log.py for module logging
Type aliases defined at module level for clarity
Use Final[type] as type hint for all constants
All functions require docstrings with brief descriptions
Complete type annotations for parameters and return types in functions
Use typing_extensions.Self for model validators in Pydantic models
Use modern union type syntax str | int instead of Union[str, int]
Use Optional[Type] for optional type hints
Use snake_case with descriptive, action-oriented function names (get_, validate_, check_)
Avoid in-place parameter modification anti-patterns; return new data structures instead
Use async def for I/O operations and external API calls
Handle APIConnectionError from Llama Stack in error handling
Use standard log levels with clear purposes: debug, info, warning, error
All classes require descriptive docstrings explaining purpose
Use PascalCase for class names with standard suffixes: Configuration, Error/Exception, Resolver, Interface
Use ABC for abstract base classes with @abstractmethod decorators
Use @model_validator and @field_validator for Pydantic model validation
Complete type annotations for all class attributes; use specific types, not Any
Follow Google Python docstring conventions with Parameters, Returns, Raises, and Attributes sections

Files:

  • docs/demos/lcore/weak_points_for_ai/ex4.py
  • docs/demos/lcore/weak_points_for_ai/ex3.py
  • docs/demos/lcore/weak_points_for_ai/ex2.py
  • docs/demos/lcore/weak_points_for_ai/ex6.py
  • docs/demos/lcore/weak_points_for_ai/ex1.py
  • docs/demos/lcore/weak_points_for_ai/ex7.py
  • docs/demos/lcore/weak_points_for_ai/ex5.py
🧠 Learnings (4)
📚 Learning: 2026-04-19T15:40:25.624Z
Learnt from: CR
Repo: lightspeed-core/lightspeed-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-19T15:40:25.624Z
Learning: Use `uv run make verify` to run all linters (black, pylint, pyright, ruff, docstyle, check-types)

Applied to files:

  • .github/workflows/pydocstyle.yaml
  • .github/workflows/black.yaml
  • .github/workflows/ruff.yaml
  • Makefile
📚 Learning: 2026-04-19T15:40:25.624Z
Learnt from: CR
Repo: lightspeed-core/lightspeed-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-19T15:40:25.624Z
Learning: Use `uv run make format` to auto-format code with black + ruff

Applied to files:

  • .github/workflows/black.yaml
  • .github/workflows/ruff.yaml
  • Makefile
📚 Learning: 2026-04-16T19:08:38.217Z
Learnt from: Lifto
Repo: lightspeed-core/lightspeed-stack PR: 1524
File: src/app/endpoints/responses.py:523-529
Timestamp: 2026-04-16T19:08:38.217Z
Learning: In lightspeed-stack (`src/app/endpoints/responses.py`), the predicate `server_label in configured_mcp_labels` is the established, intentional pattern for identifying server-deployed MCP tools across `_sanitize_response_dict`, `_is_server_mcp_output_item`, and `_should_filter_mcp_chunk`. Client-supplied tools cannot collide with configured server labels because `server_label` is a server-side field set by lightspeed-stack during tool injection; clients send `function` tools or MCP tools pointing at their own servers with different labels. Do not flag this predicate as a false-positive collision risk in code review.

Applied to files:

  • docs/demos/lcore/weak_points_for_ai/ex5.py
📚 Learning: 2026-02-25T07:46:39.608Z
Learnt from: asimurka
Repo: lightspeed-core/lightspeed-stack PR: 1211
File: src/models/responses.py:8-16
Timestamp: 2026-02-25T07:46:39.608Z
Learning: In the lightspeed-stack codebase, src/models/requests.py uses OpenAIResponseInputTool as Tool while src/models/responses.py uses OpenAIResponseTool as Tool. This type difference is intentional - input tools and output/response tools have different schemas in llama-stack-api.

Applied to files:

  • docs/demos/lcore/weak_points_for_ai/ex5.py
🪛 HTMLHint (1.9.2)
docs/demos/lcore/weak_points_for_ai.html

[warning] 2-2: An lang attribute must be present on elements.

(html-lang-require)

🪛 LanguageTool
docs/demos/lcore/weak_points_for_ai.md

[grammar] ~30-~30: Ensure spelling is correct
Context: ...red to other Python-based apps) * A bit complection was already "achieved" --- ## Weak po...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[grammar] ~37-~37: Ensure spelling is correct
Context: ...oints in LCORE * Consistency * Risk of complection * Risk of having too many ad-hoc data t...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[style] ~46-~46: ‘Overall structure’ might be wordy. Consider a shorter alternative.
Context: ...or LLMs) - just few places --- ## Overall structure * Stateful REST API * Without global m...

(EN_WORDINESS_PREMIUM_OVERALL_STRUCTURE)


[style] ~58-~58: To form a complete sentence, be sure to include a subject.
Context: ... --- ## Static vs dynamic structure * Might be critical for LLMs to understand the ...

(MISSING_IT_THERE)


[grammar] ~350-~350: Use a hyphen to join words.
Context: ... description stored in AGENTS.md * Low level consistency - syntax level ...

(QB_NEW_EN_HYPHEN)


[style] ~355-~355: To elevate your writing, try using a synonym here.
Context: ...sistency - architecture level - hard to check and maintain --- ## Python f...

(HARD_TO)

🔇 Additional comments (3)
docs/demos/lcore/weak_points_for_ai/ex6.py (1)

1-12: LGTM — illustrative anti-pattern is clearly framed.

The leading comments make it explicit that the magic-number usage is the weak point being demonstrated, so this serves the demo deck as intended.

docs/demos/lcore/weak_points_for_ai.html (1)

7-23: Reveal.js assets are properly vendored and reachable.

All referenced CSS and JS files exist in the repository at the correct relative paths (dist/reset.css, dist/reveal.css, dist/theme/simple.css, plugin/highlight/github.css, dist/reveal.js, plugin/notes/notes.js, plugin/markdown/markdown.js, plugin/highlight/highlight.js). The file follows the same asset structure as all other existing demo HTMLs in docs/demos/lcore/ and will render correctly without silent failure.

			> Likely an incorrect or invalid review comment.
.github/workflows/black.yaml (1)

20-20: CI and Makefile black targets are now consistent

The change correctly aligns the CI workflow with the updated Makefile black target (line 102). Both now check src tests.

Note: The format target in the Makefile (line 58) still uses black ., which was already flagged in the Makefile review.

python-version: '3.12'
- name: Python linter
run: uv tool run pydocstyle -v .
run: uv tool run pydocstyle -v src tests
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Inconsistency with Makefile docstyle target

This CI workflow now checks src tests, but the Makefile docstyle target (line 111) only checks src. Developers running make verify locally will not catch docstring issues in tests/.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/pydocstyle.yaml at line 20, The CI pydocstyle invocation
checks both src and tests but the Makefile docstyle target only checks src,
causing local `make verify` to miss test docstring issues; update the Makefile
target named "docstyle" so its pydocstyle invocation matches the workflow (run
pydocstyle -v src tests) — locate the docstyle target in the Makefile and add
"tests" to the paths checked (or unify both CI and Makefile to use the same path
list).

python-version: '3.12'
- name: Python linter
run: uv tool run ruff check . --per-file-ignores=tests/*:S101 --per-file-ignores=scripts/*:S101
run: uv tool run ruff check src tests --per-file-ignores=tests/*:S101 --per-file-ignores=scripts/*:S101
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Redundant ignore pattern for scripts/*

The --per-file-ignores=scripts/*:S101 flag has no effect since the checked scope is now src tests and does not include the scripts directory.

♻️ Cleanup redundant flag
-        run: uv tool run ruff check src tests --per-file-ignores=tests/*:S101 --per-file-ignores=scripts/*:S101
+        run: uv tool run ruff check src tests --per-file-ignores=tests/*:S101
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
run: uv tool run ruff check src tests --per-file-ignores=tests/*:S101 --per-file-ignores=scripts/*:S101
run: uv tool run ruff check src tests --per-file-ignores=tests/*:S101
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/ruff.yaml at line 20, Remove the redundant
per-file-ignores flag from the ruff invocation: the command "uv tool run ruff
check src tests --per-file-ignores=tests/*:S101
--per-file-ignores=scripts/*:S101" should be simplified to omit
"--per-file-ignores=scripts/*:S101" since ruff is only checking "src" and
"tests"; keep the tests ignore only.

@@ -0,0 +1,36 @@
<!doctype html>
<html>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add lang attribute on <html> for accessibility.

Screen readers and validators expect a language hint on the root element.

♻️ Proposed fix
-<html>
+<html lang="en">
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<html>
<html lang="en">
🧰 Tools
🪛 HTMLHint (1.9.2)

[warning] 2-2: An lang attribute must be present on elements.

(html-lang-require)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/demos/lcore/weak_points_for_ai.html` at line 2, Add a lang attribute to
the root HTML element (the <html> tag) to provide a language hint for screen
readers and validators; update the <html> tag in
docs/demos/lcore/weak_points_for_ai.html (the root <html> element) to include an
appropriate language code (for example lang="en" or the correct locale for the
document) and ensure any related tooling or templates that generate this file
also propagate that attribute.

Comment thread docs/demos/lcore/weak_points_for_ai.md Outdated
Comment on lines +264 to +306
if filtered_tool_names:
result = []
for tool in tools:
tool_dict = tool if isinstance(tool, dict) else tool.model_dump()
tool_type = tool_dict.get("type")

if tool_type == "mcp" and len(filtered_tool_names) > 0:
# Get the endpoint for this MCP config
mcp_endpoint = tool_dict.get("server_url", "")
server_label = tool_dict.get("server_label", "unknown")

# Filter to only include tools that belong to this endpoint
endpoint_tools = [
tool_name
for tool_name in filtered_tool_names
if tool_to_endpoint.get(tool_name) == mcp_endpoint
]

if endpoint_tools:
if isinstance(tool, dict):
tool["allowed_tools"] = endpoint_tools
else:
tool.allowed_tools = endpoint_tools
result.append(tool)
else:
logger.warning(
"MCP server %s (%s) has no matching tools - skipping from result",
server_label,
mcp_endpoint,
)
else:
# Non-MCP tools (file_search, function) are always included
logger.debug(
"Including non-MCP tool: type=%s, config=%s",
tool_type,
tool_dict.get("name") if tool_type == "function" else tool_type,
)
result.append(tool)

)
return result
return []
```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Stray ) in displayed Python snippet — invalid syntax on the slide.

Inside the _filter_tools_for_response snippet, the loop body ends at result.append(tool) (line 301), then there is a lone ) on line 303 before return result. This is a copy-paste artifact and will render as a syntax error on the slide (and break syntax highlighting around that point).

♻️ Proposed fix
                 logger.debug(
                     "Including non-MCP tool: type=%s, config=%s",
                     tool_type,
                     tool_dict.get("name") if tool_type == "function" else tool_type,
                 )
                 result.append(tool)
 
-        )
         return result
     return []
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if filtered_tool_names:
result = []
for tool in tools:
tool_dict = tool if isinstance(tool, dict) else tool.model_dump()
tool_type = tool_dict.get("type")
if tool_type == "mcp" and len(filtered_tool_names) > 0:
# Get the endpoint for this MCP config
mcp_endpoint = tool_dict.get("server_url", "")
server_label = tool_dict.get("server_label", "unknown")
# Filter to only include tools that belong to this endpoint
endpoint_tools = [
tool_name
for tool_name in filtered_tool_names
if tool_to_endpoint.get(tool_name) == mcp_endpoint
]
if endpoint_tools:
if isinstance(tool, dict):
tool["allowed_tools"] = endpoint_tools
else:
tool.allowed_tools = endpoint_tools
result.append(tool)
else:
logger.warning(
"MCP server %s (%s) has no matching tools - skipping from result",
server_label,
mcp_endpoint,
)
else:
# Non-MCP tools (file_search, function) are always included
logger.debug(
"Including non-MCP tool: type=%s, config=%s",
tool_type,
tool_dict.get("name") if tool_type == "function" else tool_type,
)
result.append(tool)
)
return result
return []
```
if filtered_tool_names:
result = []
for tool in tools:
tool_dict = tool if isinstance(tool, dict) else tool.model_dump()
tool_type = tool_dict.get("type")
if tool_type == "mcp" and len(filtered_tool_names) > 0:
# Get the endpoint for this MCP config
mcp_endpoint = tool_dict.get("server_url", "")
server_label = tool_dict.get("server_label", "unknown")
# Filter to only include tools that belong to this endpoint
endpoint_tools = [
tool_name
for tool_name in filtered_tool_names
if tool_to_endpoint.get(tool_name) == mcp_endpoint
]
if endpoint_tools:
if isinstance(tool, dict):
tool["allowed_tools"] = endpoint_tools
else:
tool.allowed_tools = endpoint_tools
result.append(tool)
else:
logger.warning(
"MCP server %s (%s) has no matching tools - skipping from result",
server_label,
mcp_endpoint,
)
else:
# Non-MCP tools (file_search, function) are always included
logger.debug(
"Including non-MCP tool: type=%s, config=%s",
tool_type,
tool_dict.get("name") if tool_type == "function" else tool_type,
)
result.append(tool)
return result
return []
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/demos/lcore/weak_points_for_ai.md` around lines 264 - 306, Remove the
stray closing parenthesis after the loop in the _filter_tools_for_response
snippet (the lone ')' following result.append(tool)) which causes a syntax
error; delete that extraneous character so the function returns result properly
and ensure indentation of the return result line remains aligned with the if
filtered_tool_names: block.

Comment on lines +144 to +148
result.append(tool)

)
return result
return []
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Stray ) on line 146 — syntax error in the demo snippet.

Line 146 contains a lone ) that does not close any opening delimiter in the surrounding scope. As written, this snippet won't parse as valid Python and will likely confuse readers of the slide deck. It looks like a leftover from a removed comprehension/call wrapper.

🛠 Proposed fix
                 result.append(tool)
 
-        )
         return result
     return []
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/demos/lcore/weak_points_for_ai/ex5.py` around lines 144 - 148, The
snippet has a stray closing parenthesis after result.append(tool) causing a
SyntaxError; remove the extraneous ')' so the loop appends correctly (look for
the result.append(tool) statement inside the function that builds and returns
result) and ensure the function returns result or [] as intended.

Comment thread Makefile

black: ## Check source code using Black code formatter
uv run black --check .
uv run black --check src tests
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Extract all linting/formatting commands to verify scope consistency

echo "=== Makefile linting targets ==="
rg -A1 '^(black|ruff|pylint|pyright|docstyle|format):' Makefile

echo -e "\n=== CI workflow linting commands ==="
rg 'run:.*\b(black|ruff|pydocstyle)' .github/workflows/

Repository: lightspeed-core/lightspeed-stack

Length of output: 1005


🏁 Script executed:

cat -n Makefile | grep -A 5 "^[[:space:]]*format:"

Repository: lightspeed-core/lightspeed-stack

Length of output: 58


🏁 Script executed:

cat -n Makefile | grep -A 10 "^[[:space:]]*verify:"

Repository: lightspeed-core/lightspeed-stack

Length of output: 58


🏁 Script executed:

# Get more context around the targets
rg -B1 -A 3 '(format|verify|ruff|docstyle):' Makefile

Repository: lightspeed-core/lightspeed-stack

Length of output: 469


Fix inconsistent linting scope across Makefile targets and add missing linters to verify target

The black target uses src tests but several related targets remain inconsistent:

  • format target (lines 58–59): both black and ruff still use . instead of src tests
  • ruff target (line 114): uses . instead of src tests (CI uses src tests)
  • docstyle target (line 111): uses only src instead of src tests (CI uses src tests)
  • verify target (missing): does not run ruff or docstyle at all, despite the learning noting it should run all linters (black, pylint, pyright, ruff, docstyle)

The scope inconsistency between Makefile and CI workflows, combined with the incomplete verify target, causes local verification to not match CI and misses linting checks.

Suggested fixes for consistency
 format: ## Format the code into unified format
-	uv run black .
-	uv run ruff check . --fix
+	uv run black src tests
+	uv run ruff check src tests --fix --per-file-ignores=tests/*:S101 --per-file-ignores=scripts/*:S101
 ruff:	## Check source code using Ruff linter
-	uv run ruff check . --per-file-ignores=tests/*:S101 --per-file-ignores=scripts/*:S101
+	uv run ruff check src tests --per-file-ignores=tests/*:S101 --per-file-ignores=scripts/*:S101
 docstyle:	## Check the docstring style using Docstyle checker
-	uv run pydocstyle -v src
+	uv run pydocstyle -v src tests
 verify:	## Run all linters
 	$(MAKE) black
 	$(MAKE) pylint
 	$(MAKE) pyright
+	$(MAKE) ruff
+	$(MAKE) docstyle
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` at line 102, Makefile targets use inconsistent lint scopes and the
verify target is missing linters; update the black, ruff, docstyle, and format
targets to use the same scope as CI (src tests) instead of . or only src, and
modify or add the verify target so it invokes all linters (black, ruff,
docstyle, pylint, pyright) — reference the Makefile targets named format, black,
ruff, docstyle, and verify to locate and change their commands so local checks
match CI and include the missing linters.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@tisnik tisnik merged commit 0c14ee8 into lightspeed-core:main Apr 26, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant