2025年9月24日水曜日

Modernizing Java Projects with GitHub Copilot Agent Mode: A Step-by-Step Guide

 Modernizing legacy Java applications can feel like trying to fix a plane mid-flight — especially when you're juggling outdated dependencies, deprecated APIs, or prepping for a cloud migration. But there’s good news: GitHub Copilot agent mode is here to turn that headache into a streamlined, guided workflow.

In this post, you'll learn how to use GitHub Copilot agent mode with the App Modernization for Java extension in VS Code to automatically upgrade, fix, test, and prepare your Java apps for the cloud.

 Bonus: It’s not just for Java — .NET devs using Visual Studio can enjoy a similar guided experience!


 What is GitHub Copilot Agent Mode?

Think of Copilot agent mode as an AI-powered junior developer that doesn’t just suggest code — it understands your goals and carries out multi-step tasks with you.

Instead of typing every little instruction, you can give it a high-level prompt like:

"Upgrade this Java app to Java 21, fix deprecated APIs, and get it cloud-ready."

And just like that, Copilot will:

  • Analyze your code

  • Build an upgrade plan

  • Apply changes

  • Fix build errors

  • Suggest secure dependencies

  • Run tests

  • Even help deploy to Azure

All inside VS Code.


 What You’ll Need Before You Start

To follow along:

  • Visual Studio Code

  • GitHub Copilot license (Pro, Pro+, Business, or Enterprise)

  • GitHub Copilot App Modernization – Java extension

  • A legacy Java project (built with Maven or Gradle, JDK 8+)


 Step-by-Step: Modernizing a Java App with Copilot Agent Mode

Step 1: Open Your Java Project in VS Code

Use your own project or clone a sample:

git clone https://github.com/your-org/your-legacy-java-app.git cd your-legacy-java-app code .

Make sure it's Git-initialized and has a working test suite (unit tests preferred).


Step 2: Start an Agent Session

  • Open the Copilot chat sidebar in VS Code

  • Launch a new Agent Mode session

  • Select: "GitHub Copilot App Modernization – Upgrade for Java"

 Paste this prompt to kick things off:

"Using Java upgrade tools, upgrade this project to Java 21. Analyze deprecated APIs, update Gradle dependencies, and propose a safe, testable migration plan."


Step 3: Let Copilot Analyze & Plan

Copilot will:

  • Scan your JDK usage

  • Review build.gradle or pom.xml

  • Detect deprecated APIs

  • Flag security vulnerabilities (CVEs)

  • Create an upgrade plan (you can edit this!)

 Example output:
A structured upgrade plan in markdown with goals, target JDK version, framework upgrades, and next steps.


Step 4: Apply Upgrades & Resolve Errors

Once you approve the plan, Copilot will:

  • Update Java syntax and imports

  • Apply OpenRewrite transformations

  • Enter a build-test-fix loop until the app compiles and passes tests

 You’ll also get:

  • A change log

  • Commit history

  • API/dependency diff

  • A complete summary report

 Example Code Change

// Before (deprecated) View view = this.resolver.resolveViewName("intro", new Locale("EN")); // After (Java 21) View view = this.resolver.resolveViewName("intro", Locale.of("EN"));

Step 5: Make Your App Azure-Ready

After upgrading, it's time to prepare for the cloud. From the Copilot extension panel:

  1. Click “Migrate to Azure”

  2. Run an App Assessment to identify issues

  3. Configure your deployment target (e.g., AKS) via assessment-config.yaml

Copilot will:

  • Highlight Azure readiness gaps

  • Propose fixes (e.g., migrate from on-prem auth to Microsoft Entra ID)

  • Update dependencies and configs

  • Write documentation

  • Validate everything

 Sample changes include:

  • build.gradle updates (adding Entra ID support)

  • New application.properties entries

  • Custom Spring Security config for Entra ID

  • Markdown docs for dev teams


Step 6: Run Tests & Validate Everything

Once your migration is done, Copilot helps run and validate tests:

 Run manually:

./mvnw test # for Maven ./gradlew test # for Gradle

If any test fails, Copilot can help debug or suggest new tests.

 CVE Scanning

Copilot also performs automatic CVE scans and suggests secure dependency replacements — essential for maintaining compliance.

Example:
No known CVEs found for spring-cloud-azure-starter-active-directory:5.22.0


Step 7: Deploy to Azure (Automatically!)

Once everything checks out, deploy with one click:

  • Provision infrastructure (or use existing)

  • Deploy your app to Azure

  • Get full logs, status, and monitoring setup

 Deployment report includes:

  • 6 Azure resources provisioned

  • Auto-scaling enabled

  • Monitoring via App Insights & Log Analytics

  • Managed identity secured deployment

  • A full deployment record for documentation


 Java Modernization Complete

With GitHub Copilot agent mode and the app modernization extension, you can:

  • Modernize legacy Java apps

  • Automatically fix code issues

  • Validate with tests

  • Scan for CVEs

  • Migrate to the cloud

  • Deploy to Azure

All inside a guided, chat-driven experience in VS Code.


 Try It Today

Whether you’re upgrading Java or migrating .NET, Copilot agent mode is ready to help you:

  • Analyze large codebases

  • Plan upgrades and migrations

  • Execute changes safely

  • Cut hours of manual effort

Learn more in the GitHub Copilot Agent Mode doc

2025年9月23日火曜日

量子材料のブレイクスルーを加速!MITが開発したAIツール「SCIGEN」の衝撃

 MITの研究者たちは、生成AIを使って量子計算に役立つような「革新的な材料」を創出する新しい手法を開発しました。

その名も SCIGEN(サイジェン)。これにより、これまで発見が困難だった超伝導体や量子スピン液体などの次世代材料が一気に現実味を帯びてきました。


生成AIで材料設計が可能に?その課題とは

近年、Google、Microsoft、Metaなどの大手企業が開発した生成AIモデルを用いて、新しい材料の設計が進められています。これらのモデルは、テキストから画像を生成するのと同じ原理で、数千万にもおよぶ新しい材料候補を生み出してきました。

しかし、量子特性(例:超伝導や特異な磁気状態)を持つ材料の創出には限界がありました。
なぜなら、これらの特性は非常に繊細な原子構造のパターンに依存しており、既存のAIモデルはそれを考慮できなかったからです。

例:量子スピン液体という量子計算に革命をもたらす可能性のある材料も、10年かけてわずか十数種類しか発見されていません。


解決策:構造制約付きAI生成「SCIGEN」

MITの研究チームが今回開発したSCIGENStructural Constraint Integration in GENerative modelの略)は、生成AIに幾何学的な「構造ルール」を与えることができる革新的なツールです。

これにより、以下のような量子特性を生み出す原子構造をAIが「意図的に」生成できるようになります:

  • カゴメ格子(上下逆さの三角形が重なった幾何構造)

  • リーブ格子(対称性の高い特殊な正方形構造)

  • アルキメデス格子(異なる多角形のタイルでできた2次元格子)

🔬「我々が求めているのは、1000万個の安定した材料ではありません。世界を変える“たった一つの材料”です」
── MIT・李明達(Mingda Li)教授


実際に2つの新材料を発見!

SCIGENは、既存のAI生成モデル(例:DiffCSP)に簡単に組み込むことができます。
研究チームは、SCIGENを使って1,000万以上の材料候補を生成し、その中から

  • 構造が安定しているものを100万件に絞り込み、

  • さらに2万6千件をスーパーコンピュータで詳細解析し、

  • 実際に2つの新しい材料(TiPdBi、TiPbSb)を合成・実証しました。

これらの新材料は、予測通り特異な磁気特性を持ち、量子コンピューティングの実用化に向けた重要な手がかりとなる可能性があります。


SCIGENの仕組みを簡単に解説

生成AI(拡散モデル)は、訓練データに基づき材料構造をランダムに生成します。
しかし、**SCIGENが「構造的なルールブック」**となり、不適切な構造は排除するため、生成される材料は最初から目的に適った形になります。

これにより、例えば以下のような目的でAIをコントロールできるようになります:

  • 特定の格子構造を持つ材料だけを生成する

  • 量子効果を発現しやすい設計ルールに基づいた候補を作る

  • 実験で合成可能な安定性のある材料に絞る


研究の意義と今後の展望

量子スピン液体など、次世代の量子材料の発見は現在も非常に困難で時間がかかります。
SCIGENは、構造的に可能性のある材料を「大量にかつ目的に沿って」生成できるため、実験研究の効率を飛躍的に高めることができます。

MITの研究チームは今後、次のような機能の追加も検討しています:

  • 化学的制約や機能的特性のルール化

  • プロンプト最適化や複合AIとの連携

  • 新しい格子構造に特化した発見アルゴリズムの導入

🧪「安定性だけを求めてもブレイクスルーは生まれません。必要なのは、新しい“可能性”の扉を開くことです」
── 論文ファーストオーサー・岡部亮太郎氏(MIT博士課程)


実用化への期待

Drexel大学のSteve May教授も次のように評価しています:

「SCIGENは、次世代の電子・磁気・光学技術に必要な、これまで探索されてこなかった材料の発見を加速する革新的なツールです。」

材料科学の世界では、たった1つの発見が未来を変えます。
SCIGENは、そんな**“世界を変える材料”を見つけるための灯台**になるかもしれません。


📄 元記事(MIT News)

New tool makes generative AI models more likely to create breakthrough materials – MIT News

Microsoftの「Agent Lightning」が切り拓く、次世代AIエージェントの訓練パラダイム

 AIエージェントはもはやSFの産物ではありません。コードの生成やツールの呼び出し、複雑なマルチターン対話の遂行、さらにはエンドツーエンドのソフトウェア開発まで――AIエージェントは、金融、ゲーム、ソフトウェア開発といったさまざまな分野で、現実のタスクを実行する存在へと進化しています。

しかし、AIエージェントの「訓練」には大きな課題が残っていました。

課題:従来の強化学習はAIエージェントと相性が悪い?

従来の強化学習(Reinforcement Learning, RL)は、ゲームやロボット制御などでは成功してきましたが、複雑で動的な環境におけるAIエージェントの訓練には向いていませんでした。
その理由は主に以下の3つです:

  • 開発コストが高い:既存のAIエージェントをRLで訓練しようとすると、大幅なコード変更が必要。

  • 拡張性がない:タスクごとにRL手法をカスタマイズしなければならず、汎用性に欠ける。

  • データが活かせない:実行時に得られるリッチなインタラクションデータが、訓練に活用しづらい。

このような状況を打破するため、Microsoft Researchが新たに開発したのが 「Agent Lightning」 です。


Agent Lightningとは?

Agent Lightning 概要図
(出典:Microsoft Research

Agent Lightning は、あらゆるAIエージェントを対象に、強化学習を用いた効率的な訓練を可能にする柔軟かつ拡張可能なフレームワークです。
最大の特徴は、「エージェントの実行」と「訓練」の完全な分離(デカップリング) を実現した点にあります。

これにより、エージェントのロジックを変更することなく、そのまま訓練が可能になります。


技術的な仕組み:LightningRLとTraining-Agentアーキテクチャ

Agent Lightningは、以下の2つの中核コンポーネントによって構成されています。

1. LightningRL:分解して訓練する新しいRL手法

  • 強化学習では、エージェントが生成した「軌跡(トレース)」から学習データを抽出し、モデルを訓練します。

  • LightningRL は、複雑なマルチステップのエージェント操作を、単一のRL問題として再構成することで、既存の強化学習アルゴリズム(PPO、DPOなど)を再利用可能にします。

  • また、「信用割当(credit assignment)」モジュールによって、報酬を各ステップにうまく分配することが可能です。

2. Training-Agent アーキテクチャ:前後分離で開発効率を向上

  • Lightning Server:訓練プロセスの中心。GPU管理やモデル更新などを担当。

  • Lightning Client:エージェントの実行とデータ収集を担う。既存コードを変更せず導入可能。

この構成により、エージェント開発者は訓練基盤の煩雑な設定を気にせず、「エージェントの設計とロジック」に集中できる ようになります。


実験結果:さまざまなタスクで有効性を実証

Agent Lightningは、以下のような現実的なタスクでその性能を検証済みです。

● Text-to-SQL(LangChain)

3つのエージェント(SQL生成、チェック、再生成)が連携する複雑なワークフローにおいて、SQL生成エージェントと再生成エージェントの性能を選択的に訓練。報酬が安定して向上し、ツール使用を伴うマルチステップ処理の最適化に成功。

● RAG(OpenAI Agent SDK)

検索拡張型の生成タスクでも、Agent Lightningは訓練を通じて持続的な性能向上を実現。現実的なRAGシナリオにも適応可能であることが証明されました。

● 数学問答+ツール利用(AutoGen)

計算ツール(電卓)を活用した問題解決において、Agent Lightningが呼び出し精度と回答正確性の両方を改善。外部ツールとの連携が必須なタスクにも強い ことが示されました。


今後の展望:RLだけじゃない、多様な最適化への応用

Agent Lightningは、今後以下の方向で進化が期待されています:

  • Prompt最適化やコンポーネント指向の最適化 への拡張(CoI=Component of Interest の概念導入)

  • 長期的な信用割当やオフポリシー学習 などの高度なRL手法との統合

  • LLM最適化向けのシステム分離アーキテクチャ(推論・訓練・実行の分離)への対応

将来的には、Agent Lightningが収集した実行データを最大限に活用することで、AIエージェントの自律的な進化を大幅に加速することが期待されています。


まとめ:AIエージェントの進化を後押しする「訓練の標準化」

従来、AIエージェントの訓練はカスタム開発が前提でしたが、Agent Lightningにより「訓練の標準化」が可能になります。

  • コードを変えずに訓練可能

  • 強化学習とツール利用の融合が容易

  • 多様なアルゴリズムやシステム構成と統合しやすい

AIエージェントが今後、社会のさまざまな分野に広く展開されるうえで、Agent Lightningはその基盤となる重要な技術となるでしょう。


📄 論文リンク
https://arxiv.org/abs/2508.03680

🔗 公式プロジェクトページ
https://www.microsoft.com/en-us/research/project/agent-lightning/