4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AgentCore Browserと使うならどっちがいい?Nova Act or Strands Agents Toolsのブラウザツール

Posted at

2つの方法を試してみました。

  • AgentCore Browser + Nova Act
  • AgentCore Browser + Strands Agents Toolsのブラウザツール

違いは、正直わからなかったです!!

AgentCore Browser + Nova Act

本日時点で、Nova Actはバージニア北部でのみ利用可能です。マネコンでワークフローを作ります。

Nova Act SDKなどをインストールします。

uv add nova-act strands-agents bedrock-agentcore

Pythonのスクリプトはこんな感じになります。

  • Strands Agentsのツールとして呼べるように@toolをつけた関数を作成
  • AgentCore SDKにあるBrowserのクライアントbrowser_sessionからURLとHeaderを取得
  • Nova ActのWorkflowを用意
  • AgentCore BrowserのURLとHeader、Nova ActのWorkflowを渡してNova Actクライアントを生成
  • Nova Actを呼ぶ
  • Strands Agentsにツールをセット
from bedrock_agentcore.tools.browser_client import browser_session
from nova_act import NovaAct, Workflow
from strands import Agent
from strands.models import BedrockModel
from strands.tools import tool


@tool
def browser_tool(starting_page: str, prompt: str) -> str:
    """
    ブラウザを使用しタスクを実行するNova Actツール

    Args:
        starting_page: 開始URL。ブラウザツールは、開始URLにとどまらず画面遷移をしてタスクの実行が可能
        prompt: 実行したいタスク
    """
    with browser_session("us-east-1") as client:
        ws_url, headers = client.generate_ws_headers()

        with Workflow(
            model_id="nova-act-latest",
            boto_session_kwargs={"region_name": "us-east-1"},
            workflow_definition_name="new-workflow",
        ) as workflow:
            with NovaAct(
                cdp_endpoint_url=ws_url,
                cdp_headers=headers,
                workflow=workflow,
                starting_page=starting_page,
                headless=True,
            ) as nova:
                result = nova.act_get(prompt)

    return str(result)


agent = Agent(
    model=BedrockModel(
        model_id="global.anthropic.claude-haiku-4-5-20251001-v1:0",
        region_name="us-east-1",
    ),
    tools=[browser_tool],
)

agent("今日のYahooのトップニュースはなに?")

実行結果

Running on Nova Act AWS Service.

2026-01-20 12:21:21,592 - nova_act.types.workflow - INFO - Created workflow run 019bdb5a-3560-7273-b58d-7dbc17fda781 with model nova-act-latest.

start session 019bdb5a-3688-7ee6-8c65-b4a7821edf5b on https://www.yahoo.co.jp/ logs dir /tmp/tmp_s2trt86_nova_act_logs/019bdb5a-3688-7ee6-8c65-b4a7821edf5b

df5b> act("今日のトップニュースを確認してください。最初に表示されるニュース記事のタイトルと概要を教えてください。, format output with jsonschema: {"type": "string"}")
df5b> 💭 ...
df5b> think("I am on the Yahoo Japan page. My task is to check the top news for today and return the title and summary of the first news article. I see a news section on the top navigation bar. I should click the 'トップ' link to go to the top news page. I need to click トップ link");
df5b> agentClick("<box>228,416,242,450</box>");
df5b> 👀 ...
df5b> 💭 ...
df5b> think("I am now on the Yahoo Japan news page, so my last action was successful. I can see the first news article on the page, but it is not expanded. I should click the first article link to expand the article.");
df5b> agentClick("<box>234,256,249,472</box>");
df5b> 👀 ...
df5b> 💭 ...
df5b> think("I am now on the page for the first article, so my last action was successful. I can see the title of the article, but the summary is not visible. I should scroll down to find the summary of the article.");
df5b> agentScroll("down", "<box>0,0,732,1456</box>");
df5b> 👀 ...
df5b> 💭 ...
df5b> think("I can now see the summary of the article, which means my last action was successful. I can see the title of the article is '今年最長で最強の寒波が来週 各地で猛吹雪 「前も見えな い」' and the summary is '「最長で最強の寒波」が日本列島を覆う一方で、明期はほぼ無く続いています。'. My task is complete, and I have found the title and summary of the first article. I should return the title and summary in the specified JSON format.");
df5b> return(""「今年最長で最強の寒水が来週、各地で苹吉難「前も見えない」」"");
df5b> 🎬 ...
df5b> ⏱️  Approx. Time Worked: 59.7s

df5b> ** View your act run here: /tmp/tmp_s2trt86_nova_act_logs/019bdb5a-3688-7ee6-8c65-b4a7821edf5b/act_019bdb5a-5bf8-7210-836d-12a342e897ca_今日のトップニュースを確認してください。最初に表示されるニュ.html

df5b> ⏱️  Approx. Total Time Worked in Session: 59.7s across 1 act call

end session: 019bdb5a-3688-7ee6-8c65-b4a7821edf5b

2026-01-20 12:22:32,136 - nova_act.types.workflow - INFO - Updated workflow run 019bdb5a-3560-7273-b58d-7dbc17fda781 status to 'SUCCEEDED'
今日のYahooのトップニュースは以下です:

**「今年最長で最強の寒水が来週、各地で苹吉難『前も見えない』」**

来週にかけて今年最長で最強の寒波が到来するというニュースがトップで報道されているようです。各地で降雪による困難が予想され、視界が極めて悪くなるような悪天候の警告がなされているようです。

最新のニュース情報をご確認いただくには、Yahoo! JAPANのトップページ(https://www.yahoo.co.jp/)をご覧ください。

Nova Actの場合は、一回のツール呼び出しで、結果まで取得できます。

AgentCore Browser + Strands Agents Toolsのブラウザツール

続いてStrands Agents Toolsのブラウザツールを使ってみます。

uv add strands-agents bedrock-agentcore strands-agents-tools nest-asyncio

コードは凄くシンプルになります。

from strands import Agent
from strands.models import BedrockModel
from strands_tools.browser import AgentCoreBrowser

browser = AgentCoreBrowser(region="us-east-1", session_timeout=120)


agent = Agent(
    model=BedrockModel(
        model_id="global.anthropic.claude-haiku-4-5-20251001-v1:0",
        region_name="us-east-1",
    ),
    tools=[browser.browser],
)


agent("今日のYahooのトップニュースはなに?")

実行結果

Yahoo のトップニュースを確認するために、ブラウザを起動して Yahoo のページにアクセスします。
Tool #1: browser
それでは Yahoo Japan のホームページにアクセスします。
Tool #2: browser
ページが読み込まれましたので、ページのスクリーンショットを取得して、トップニュースを確認します。
Tool #3: browser
次に、トップニュース領域のテキストを抽出します。
Tool #4: browser
別の方法でページのテキストを取得します。
Tool #5: browser
HTMLが取得できたので、JavaScriptを使ってニュースセクションのテキストを抽出します。
Tool #6: browser
JavaScriptを修正します。
Tool #7: browser
JSON形式を確認してスクリプトを修正します。
Tool #8: browser
別のアプローチを試します。
Tool #9: browser
JSON変換のために文字列をエスケープします。
Tool #10: browser
完璧です!Yahoo Japan のトップニュースが取得できました。セッションを閉じます。
Tool #11: browser
## 今日のYahoo トップニュース(2026年1月20日)

Yahoo Japan のトップニュースは以下の通りです:

### **主なトップニュース:**

1. **「最長で最強の寒波」各地猛吹雪** (21:19更新)
   - 前も見えないほどの猛吹雪が各地で発生

2. **離島の国有化を検討 自民の提言案** (482件のコメント)

3. **ロゴを悪意持って改変 中道が注意** (NEW)

4. **自民大阪 維新巡り首相に異例要請** (NEW)

5. **車暴走7人重軽傷 被告が免許返納** (NEW - 267件のコメント)
   - 名古屋・栄で発生した事故について

6. **ロッテリア大量閉店 ゼッテリア増** (1045件のコメント)

### **話題の記事:**
- 米倉涼子に関する報道が複数掲載
- 大坂なおみの全豪開幕式での派手な入場
- 関東地方での大雪予報
- 相撲初場所の熱戦レポート

**最大の関心事**は、「最長で最強の寒波」が日本全国に襲来し、各地で猛吹雪が発生しているというニュースのようです。

こちらはツールが複数回呼ばれる動作になります。


まとめ

Nova Actは、以前投稿したこちらの投稿になるようにマネコンで実施ログが画面キャプチャ付きで確認できるので、そのあたりの機能はNova Actのほうが良さそうです!

4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?