Skip to content

[Feature] Improve error messages for code generation failures #22

@co01y4p

Description

@co01y4p

Is this related to a problem?
When code generation fails, error messages can be vague. Users see generic errors without clear guidance on what went wrong or how to fix it. For example, an LLM timeout and a cargo check failure return similar error formats.

Describe the feature
Add structured error codes and actionable messages to the generate_stylus_code tool:

  • ERR_LLM_TIMEOUT — "LLM request timed out. Try a simpler prompt or try again."
  • ERR_LLM_EMPTY — "LLM returned empty response. Retrying with a different model..."
  • ERR_CARGO_CHECK — "Generated code failed compilation. Error: [specific error]. Attempting auto-fix..."
  • ERR_DOCKER_UNAVAILABLE — "Docker is not running. Compile verification skipped."
  • ERR_TEMPLATE_NOT_FOUND — "No matching template for this prompt. Using freeform generation."

Which module does this relate to?

  • M1: Stylus (contracts, tests, compilation)

Example usage
Before: "Error generating code"
After: "[ERR_CARGO_CHECK] Compilation failed: missing import 'alloy_sol_types::sol'. Auto-fix attempt 1/3..."

Additional context

  • Files: src/mcp/tools/generate_stylus_code.py, src/utils/compiler_verifier.py
  • The compiler_verifier.py already has an ERROR_GUIDANCE dict mapping Rust error codes to fix hints — this can be exposed to users

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions