Skip to content

Conversation

@TonsOfFun
Copy link
Contributor

@TonsOfFun TonsOfFun commented Aug 22, 2025

closes #206

dummy(dev)> ScrapingAgent.with(message: "Are there any notices on the Google homepage?").prompt_context.generate_now
  Rendering scraping_agent/instructions.text.erb
  Rendered scraping_agent/instructions.text.erb (Duration: 1.3ms | GC: 0.0ms)
  Rendering layout layouts/agent.json.erb
  Rendering scraping_agent/read_current_page.json.erb within layouts/agent
  Rendered scraping_agent/read_current_page.json.erb within layouts/agent (Duration: 0.3ms | GC: 0.0ms)
  Rendered layout layouts/agent.json.erb (Duration: 0.5ms | GC: 0.0ms)
  Rendering layout layouts/agent.json.erb
  Rendering scraping_agent/visit.json.erb within layouts/agent
  Rendered scraping_agent/visit.json.erb within layouts/agent (Duration: 0.2ms | GC: 0.0ms)
  Rendered layout layouts/agent.json.erb (Duration: 0.3ms | GC: 0.0ms)
Stubbing always successful navigation to https://www.google.com
  Rendering scraping_agent/instructions.text.erb
  Rendered scraping_agent/instructions.text.erb (Duration: 0.2ms | GC: 0.0ms)
  Rendering layout layouts/agent.text.erb
  Rendering scraping_agent/visit.text.erb within layouts/agent
  Rendered scraping_agent/visit.text.erb within layouts/agent (Duration: 0.7ms | GC: 0.0ms)
  Rendered layout layouts/agent.text.erb (Duration: 1.1ms | GC: 0.0ms)
  Rendering layout layouts/agent.json.erb
  Rendering scraping_agent/read_current_page.json.erb within layouts/agent
  Rendered scraping_agent/read_current_page.json.erb within layouts/agent (Duration: 0.2ms | GC: 0.0ms)
  Rendered layout layouts/agent.json.erb (Duration: 0.3ms | GC: 0.0ms)
Stubbing a read of Google homepage under maintenance (regardless of URL, for testing)
  Rendering scraping_agent/instructions.text.erb
  Rendered scraping_agent/instructions.text.erb (Duration: 0.2ms | GC: 0.0ms)
  Rendering layout layouts/agent.text.erb
  Rendering scraping_agent/read_current_page.text.erb within layouts/agent
  Rendered scraping_agent/read_current_page.text.erb within layouts/agent (Duration: 0.4ms | GC: 0.0ms)
  Rendered layout layouts/agent.text.erb (Duration: 0.5ms | GC: 0.0ms)
  Rendering layout layouts/agent.json.erb
  Rendering scraping_agent/visit.json.erb within layouts/agent
  Rendered scraping_agent/visit.json.erb within layouts/agent (Duration: 0.1ms | GC: 0.0ms)
  Rendered layout layouts/agent.json.erb (Duration: 0.2ms | GC: 0.0ms)
=> 
#<ActiveAgent::GenerationProvider::Response:0x000000011c5166d0
 @message=
  #<ActiveAgent::ActionPrompt::Message:0x328c
    @action_id=nil,
    @action_name=nil,
    @action_requested=false,
    @charset="UTF-8",
    @content="Yes, there is a notice on the Google homepage stating that \"Google is under maintenance until 13:15 UTC.\"",
    @role=:assistant>,
 @metadata={},
 @prompt=
  #<ActiveAgent::ActionPrompt::Prompt:0x32a0
  @options={:model=>"gpt-4o-mini", "service"=>"OpenAI", "access_token"=>"<OPENAI_ACCESS_TOKEN>", "model"=>"gpt-4o-mini", "temperature"=>0.7}
  @actions=[{"type"=>"function", "function"=>{"name"=>"visit", "description"=>"Navigates the browser to the provided URL", "parameters"=>{"type"=>"object", "properties"=>{"url"=>{"type"=>"string", "description"=>"The url to visit"}}, "required"=>["url"]}, "returns"=>{"type"=>"string", "description"=>"The status of the response"}}}]
  @action_choice=""
  @instructions="You are a scraping agent. You have a stateful browser attached to you.\nYour goal is to extract ONLY user requested data by using the provided actions."
  @message=#<ActiveAgent::ActionPrompt::Message:0x328c
    @action_id=nil,
    @action_name=nil,
    @action_requested=false,
    @charset="UTF-8",
    @content="Yes, there is a notice on the Google homepage stating that \"Google is under maintenance until 13:15 UTC.\"",
    @role=:assistant>
  @output_schema=
  @headers={}
  @context=[]
  @messages=[#<ActiveAgent::ActionPrompt::Message:0x32b4
    @action_id=nil,
    @action_name=nil,
    @action_requested=false,
    @charset="UTF-8",
    @content="You are a scraping agent. You have a stateful browser attached to you.\nYour goal is to extract ONLY user requested
 data by using the provided actions.",
    @role=:system>, #<ActiveAgent::ActionPrompt::Message:0x32c8
    @action_id=nil,
    @action_name=nil,
    @action_requested=false,
    @charset="UTF-8",
    @content="Are there any notices on the Google homepage?",
    @role=:user>, #<ActiveAgent::ActionPrompt::Message:0x32dc
    @action_id=nil,
    @action_name=nil,
    @action_requested=true,
    @charset="UTF-8",
    @content="",
    @role=:assistant>, #<ActiveAgent::ActionPrompt::Message:0x32f0
    @action_id="call_rCwcSlppdKpZrlXcFm6BcmuC",
    @action_name="visit",
    @action_requested=false,
    @charset="UTF-8",
    @content="Navigation resulted in 200 status code.\n",
    @role=:tool>, #<ActiveAgent::ActionPrompt::Message:0x3304
    @action_id=nil,
    @action_name=nil,
    @action_requested=true,
    @charset="UTF-8",
    @content="",
    @role=:assistant>, #<ActiveAgent::ActionPrompt::Message:0x3318
    @action_id="call_KHX8w73JtvxhHDFxbyKU0c5z",
    @action_name="read_current_page",
    @action_requested=false,
    @charset="UTF-8",
    @content="Title: Google\nBody: Welcome to Google! Google is under maintenance until 13:15 UTC.\n",
    @role=:tool>, #<ActiveAgent::ActionPrompt::Message:0x328c
    @action_id=nil,
    @action_name=nil,
    @action_requested=false,
    @charset="UTF-8",
    @content="Yes, there is a notice on the Google homepage stating that \"Google is under maintenance until 13:15 UTC.\"",
    @role=:assistant>]
>,
 @raw_request=
  {:model=>"gpt-4o-mini",
   :messages=>
    [{:role=>"system",
      :content=>
       "You are a scraping agent. You have a stateful browser attached to you.\nYour goal is to extract ONLY user requested data 
by using the provided actions."},
     {:role=>"user", :content=>"Are there any notices on the Google homepage?"},
     {:role=>"assistant",
      :content=>"",
      :tool_calls=>
       [{:id=>"call_rCwcSlppdKpZrlXcFm6BcmuC",
         :type=>"function",
         :function=>{:name=>"visit", :arguments=>"{\"url\":\"https://www.google.com\"}"}}]},
     {:role=>"tool",
      :content=>"Navigation resulted in 200 status code.\n",
      :tool_call_id=>"call_rCwcSlppdKpZrlXcFm6BcmuC",
      :name=>"visit"},
     {:role=>"assistant",
      :content=>"",
      :tool_calls=>
       [{:id=>"call_KHX8w73JtvxhHDFxbyKU0c5z", :type=>"function", :function=>{:name=>"read_current_page", :arguments=>"{}"}}]},
     {:role=>"tool",
      :content=>"Title: Google\nBody: Welcome to Google! Google is under maintenance until 13:15 UTC.\n",
      :tool_call_id=>"call_KHX8w73JtvxhHDFxbyKU0c5z",
      :name=>"read_current_page"}],
   :temperature=>0.7,
   :tools=>
    [{"type"=>"function",
      "function"=>
       {"name"=>"visit",
        "description"=>"Navigates the browser to the provided URL",
        "parameters"=>
         {"type"=>"object", "properties"=>{"url"=>{"type"=>"string", "description"=>"The url to visit"}}, "required"=>["url"]},
        "returns"=>{"type"=>"string", "description"=>"The status of the response"}}}]},
 @raw_response=
  {"id"=>"chatcmpl-C7FAlDR4w8gQQfYxOJuuocbuo7ZO8",
   "object"=>"chat.completion",
   "created"=>1755842655,
   "model"=>"gpt-4o-mini-2024-07-18",
   "choices"=>
    [{"index"=>0,
      "message"=>
       {"role"=>"assistant",
        "content"=>"Yes, there is a notice on the Google homepage stating that \"Google is under maintenance until 13:15 UTC.\"",
        "refusal"=>nil,
        "annotations"=>[],
        "id"=>"chatcmpl-C7FAlDR4w8gQQfYxOJuuocbuo7ZO8"},
      "logprobs"=>nil,
      "finish_reason"=>"stop"}],
   "usage"=>
    {"prompt_tokens"=>164,
     "completion_tokens"=>25,
     "total_tokens"=>189,
     "prompt_tokens_details"=>{"cached_tokens"=>0, "audio_tokens"=>0},
     "completion_tokens_details"=>
      {"reasoning_tokens"=>0, "audio_tokens"=>0, "accepted_prediction_tokens"=>0, "rejected_prediction_tokens"=>0}},
   "service_tier"=>"default",
   "system_fingerprint"=>"fp_560af6e559"}>

@TonsOfFun TonsOfFun merged commit 2d1e68c into fix-openrouter-headers Aug 22, 2025
5 checks passed
TonsOfFun added a commit that referenced this pull request Aug 22, 2025
* Ensuring openrouter headers are being set properly

* Removing validation test script

* Adding raw request object

* Linting

* Testing multiturn actions (#205)

* Testing multiturn actions

* Updating tool tests

* Updating scraping test example

* Linting

* Ensuring action prompts render properly

* Ensuring system messages are retained throughout continued generation

* Testing system message permanence and linting
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.

2 participants