Skip to content

Conversation

@neelay-aign
Copy link
Collaborator

No description provided.

pass

# Not a valid run_id, try to find a run by external_id
runs = list(client.runs.list(external_id=identifier, page_size=1))
Copy link

Choose a reason for hiding this comment

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

Bug: The token command always exits with an error code (1) due to a misplaced sys.exit(1) call, even on successful execution.
Severity: HIGH

Suggested Fix

Move the sys.exit(1) call to be inside the except Exception as e: block. This ensures that the command only exits with an error code when an exception is actually caught, and exits with the default success code (0) otherwise.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/aignostics/mcp/_server.py#L120

Potential issue: In the `token` command function within
`src/aignostics/platform/_cli.py`, the `sys.exit(1)` call is incorrectly placed at the
end of the function, outside of the `except` block. As a result, the command will always
exit with a status code of 1, indicating an error, even when the token is successfully
retrieved and printed. This behavior breaks standard command-line tool conventions,
where a zero exit code signifies success, and will cause issues for any scripts or
automation that rely on the exit code to determine the command's outcome.

Did we get this right? 👍 / 👎 to inform future reviews.

@codecov
Copy link

codecov bot commented Jan 23, 2026

Codecov Report

❌ Patch coverage is 65.54455% with 174 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/aignostics/mcp/_server.py 66.74% 105 Missing and 40 partials ⚠️
src/aignostics/platform/_client.py 12.50% 14 Missing ⚠️
src/aignostics/platform/_cli.py 20.00% 8 Missing ⚠️
src/aignostics/mcp/__main__.py 0.00% 6 Missing ⚠️
src/aignostics/platform/_service.py 66.66% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/aignostics/mcp/__init__.py 100.00% <100.00%> (ø)
src/aignostics/mcp/_settings.py 100.00% <100.00%> (ø)
src/aignostics/platform/_service.py 73.68% <66.66%> (-0.19%) ⬇️
src/aignostics/mcp/__main__.py 0.00% <0.00%> (ø)
src/aignostics/platform/_cli.py 78.16% <20.00%> (-7.56%) ⬇️
src/aignostics/platform/_client.py 81.98% <12.50%> (-11.71%) ⬇️
src/aignostics/mcp/_server.py 66.74% <66.74%> (ø)

... and 9 files with indirect coverage changes

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
11 New issues
70.4% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

run_server()


if __name__ == "__main__":
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we ever expect to execute this script directly?


# Download
if artifact.download_url:
response = requests.get(artifact.download_url, timeout=300)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This could reuse the download_file function to get integrity checking out of the box.

return Run(self._api, run_id)

@classmethod
def _from_token(cls, token: str) -> "Client":
Copy link
Collaborator Author

@neelay-aign neelay-aign Jan 23, 2026

Choose a reason for hiding this comment

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

Can probably be gotten rid of now. There were some auth issues in early development which were solved using this explicit method. Will investigate.

Comment on lines +10 to +21
class Environment(StrEnum):
"""Platform environment options."""

PRODUCTION = "production"
STAGING = "staging"


# Environment API roots
ENV_API_ROOTS = {
Environment.PRODUCTION: "https://platform.aignostics.com",
Environment.STAGING: "https://platform-staging.aignostics.com",
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

The API root is already defined in the settings. I'd suggest pulling it from there.

Copy link
Collaborator

Choose a reason for hiding this comment

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

(Agree in principle with controlling the URLs with a single environment setting but then we should propagate that change to the entire SDK).

Comment on lines +30 to +42
def get_readouts_dir() -> Path:
"""Get the readouts directory from environment or use default.
The directory can be configured via AIGNOSTICS_MCP_READOUTS_DIR.
Default is ~/aignostics_readouts (visible in home directory).
Returns:
Path to the readouts directory.
"""
env_dir = os.environ.get("AIGNOSTICS_MCP_READOUTS_DIR")
if env_dir:
return Path(env_dir)
return DEFAULT_CACHE_DIR
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggest using the cache_dir defined in the settings.

Additionally, if I understand the current implementation correctly, users could easily end up downloading readouts twice:

  • Once when they download run results using the GUI or CLI (application run result download ...) -> readouts are downloaded to <cache_dir>/results/<run_id>/<external_item_id>/...
  • Once when they work with the readouts in the MCP server -> readouts are downloaded to a different location

Ideally, we would use the same location: if the user already downloaded all results for a run, the MCP server should simply open those without downloading them again.

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.

3 participants