Skip to content

Code Agent

The Code Agent lets you transform your source code in three main ways: moving it to a new programming language, modernizing it with the latest best practices, or fixing security issues. It uses a powerful language model to understand your code and produce the desired changes.

How it Works

When you drop your source code into the Code Agent, it sends the code to a language model that has been trained on many programming languages. The model reads the code, follows the instructions you give (like “convert to Python” or “fix security bugs”), and writes back the updated code. All of this happens inside the Nappai dashboard, so you don’t need to run any external tools or write scripts yourself.

Operations

This component offers several operations that you can select based on what you need to do. You can only use one operation at a time:

  • Code Language migration: Move your code from one programming language to another (for example, from Java to Python).
  • Code modernization: Update your code to use newer language features, libraries, or coding styles.
  • Code security fix: Scan your code for common security problems and automatically apply fixes.

To use the component, first select the operation you need in the “Operation” field.

Inputs

  • Language Model: The AI model that will read and rewrite your code.

    • Visible in: Code Language migration, Code modernization, Code security fix
  • Sources: The source code you want to transform.

    • Visible in: Code Language migration, Code modernization, Code security fix
  • Operations: The type of operation you want to perform.

    • Visible in: Code Language migration, Code modernization, Code security fix
  • Conversion Type: The specific kind of conversion you want (e.g., “Full migration”, “Partial update”).

    • Visible in: Code Language migration, Code modernization, Code security fix
  • Enable Retries: If the AI fails to finish, the system will try again automatically.

    • Visible in: Code Language migration, Code modernization, Code security fix
  • Enable Streaming: Show the AI’s output as it is being generated, instead of waiting for the whole result.

    • Visible in: Code Language migration, Code modernization, Code security fix
  • Max Execution Steps: How many steps the AI can take to finish the task before it stops.

    • Visible in: Code Language migration, Code modernization, Code security fix
  • Source Language: The programming language of the code you are sending in.

    • Visible in: Code Language migration, Code modernization, Code security fix
  • Target Language: The programming language you want the code converted to (only used for migration).

    • Visible in: Code Language migration, Code modernization, Code security fix

Outputs

  • Data: The transformed source code returned as a data object.
  • Text: A message that describes what the agent did, returned as a text string.

These outputs can be fed into other components, such as a code editor, a deployment pipeline, or a notification system.

Usage Example

Example 1 – Code Language migration

  1. Drag the Code Agent onto the canvas.
  2. In the Operation field, choose Code Language migration.
  3. Set Source Language to “Java” and Target Language to “Python”.
  4. Paste or upload your Java source files in the Sources field.
  5. Click Run.
  6. The Data output will contain the converted Python code, which you can then send to a file writer or a version‑control component.

Example 2 – Code modernization

  1. Add the Code Agent.
  2. Select Code modernization in the Operation field.
  3. Choose the same language for Source Language and Target Language (e.g., “Python” → “Python”).
  4. Provide the source code.
  5. Run the agent.
  6. The output will be a modernized version of your code, ready to be reviewed or deployed.
  • Code Review Agent – Checks code quality and style.
  • Code Deployment Agent – Deploys code to your target environment.
  • Code Testing Agent – Generates and runs unit tests for your code.

Tips and Best Practices

  • Keep your source code files small (a few hundred lines) to avoid timeouts.
  • Use Enable Streaming if you want to see the changes as they happen.
  • Double‑check the Target Language selection; a wrong choice can produce syntax errors.
  • When migrating, review the output manually before committing to a repository.
  • For security fixes, run the agent on a copy of your code first to verify the changes.

Security Considerations

  • The Code Agent processes your code inside the Nappai environment, but the code may contain sensitive information.
  • If your code includes secrets or credentials, remove them before sending them to the agent.
  • The AI model does not store your code after the operation completes, but you should still treat the output as potentially sensitive.
  • Use the Enable Retries option only when you trust the AI to handle the same input safely; otherwise, manual intervention is safer.