Skip to content

Commit 40ad430

Browse files
add some bedrock test
1 parent 7a56ac2 commit 40ad430

6 files changed

Lines changed: 141 additions & 8 deletions

File tree

config/config.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,16 @@ config :console, :ai_defaults,
8787
},
8888
vertex: %{
8989
model: "claude-haiku-4-5@20251001",
90-
tool_model: "claude-sonnet-4-5@20250929",
90+
tool_model: "claude-sonnet-4-6@20260114",
9191
embedding_model: "gemini-embedding-001"
9292
},
9393
anthropic: %{
9494
model: "claude-4-5-haiku-latest",
95-
tool_model: "claude-4-5-sonnet-latest"
95+
tool_model: "claude-4-6-sonnet-latest"
9696
},
9797
bedrock: %{
9898
model: "us.anthropic.claude-haiku-4-5-20251001-v1:0",
99-
tool_model: "us.anthropic.claude-sonnet-4-5-20250929-v1:0",
99+
tool_model: "us.anthropic.claude-sonnet-4-6",
100100
embedding_model: "cohere.embed-english-v3"
101101
},
102102
ollama: %{},

lib/console/ai/provider/base.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ defmodule Console.AI.Provider.Base do
8989
def tool_calls({:ok, binary}), do: {:error, "no tool calls in response, got: #{binary}"}
9090
def tool_calls(err), do: err
9191

92-
defp model(name) when is_binary(name), do: LLMDB.model(name)
92+
defp model(name) when is_binary(name), do: ReqLLM.model(name)
9393
defp model(%LLMDB.Model{} = model), do: {:ok, model}
9494
defp model(model), do: {:error, "invalid model: #{inspect(model)}"}
9595

lib/console/deployments/stacks.ex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,10 +911,15 @@ defmodule Console.Deployments.Stacks do
911911
|> Repo.exists?()
912912
end
913913

914-
defp filter(%Stack{id: id}), do: StackRun.for_stack(id)
914+
defp filter(%Stack{id: id}) do
915+
StackRun.for_stack(id)
916+
|> StackRun.wet()
917+
end
918+
915919
defp filter(%PullRequest{stack_id: sid, id: id}) do
916920
StackRun.for_stack(sid)
917921
|> StackRun.for_pr(id)
922+
|> StackRun.dry()
918923
end
919924

920925
@doc """

priv/prompts/workbench/coding_output.md.eex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The coding agent completed its task. Here are the results:
66
## Summary
77
<%= @analysis.summary %>
88

9-
<%= Enum.map(@analysis.bullets, &"- #{&1}") |> Enum.join("\n") %>
9+
<%= Enum.map(@analysis.bullets || [], &"- #{&1}") |> Enum.join("\n") %>
1010

1111
## Details
1212
<%= @analysis.analysis %>
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
defmodule Console.AI.Provider.BedrockTest do
2+
use ExUnit.Case, async: false
3+
use Mimic
4+
5+
alias Console.AI.{Bedrock, Tool}
6+
alias Console.Schema.DeploymentSettings.AI.Bedrock, as: BedrockSettings
7+
alias ReqLLM.{Message, Message.ContentPart, Response, ToolCall}
8+
9+
@inference_profile_id "us.anthropic.claude-sonnet-4-6"
10+
@region "us-east-2"
11+
@usage %{input_tokens: 10, output_tokens: 5, total_tokens: 15}
12+
13+
setup :set_mimic_global
14+
15+
describe "tool_call/4" do
16+
test "calls the configured inference profile id in the Bedrock runtime REST URL" do
17+
bedrock =
18+
Bedrock.new(%BedrockSettings{
19+
tool_model_id: @inference_profile_id,
20+
region: @region,
21+
aws_access_key_id: "test-access-key",
22+
aws_secret_access_key: "test-secret-key"
23+
})
24+
25+
expected_url =
26+
"https://bedrock-runtime.#{@region}.amazonaws.com/model/#{@inference_profile_id}/converse"
27+
28+
expect(Req, :request, fn %Req.Request{} = request ->
29+
assert request.method == :post
30+
assert URI.to_string(request.url) == expected_url
31+
32+
{:ok,
33+
%Req.Response{
34+
status: 200,
35+
body: %Response{
36+
id: "test-response",
37+
model: @inference_profile_id,
38+
context: %ReqLLM.Context{messages: []},
39+
message: %Message{
40+
role: :assistant,
41+
content: [],
42+
tool_calls: [
43+
ToolCall.new("call-1", "enable_tools", ~s({"tools":["search"]}))
44+
]
45+
},
46+
finish_reason: :tool_use,
47+
usage: @usage,
48+
stream?: false
49+
}
50+
}}
51+
end)
52+
53+
assert {:ok, [%Tool{name: "enable_tools"} | _]} =
54+
Bedrock.tool_call(
55+
bedrock,
56+
[{:user, "enable search"}],
57+
[%Console.AI.Tools.EnableTools{}],
58+
[]
59+
)
60+
end
61+
end
62+
63+
describe "completion/3" do
64+
test "calls the configured inference profile id in the Bedrock runtime REST URL" do
65+
bedrock =
66+
Bedrock.new(%BedrockSettings{
67+
model_id: @inference_profile_id,
68+
region: @region,
69+
aws_access_key_id: "test-access-key",
70+
aws_secret_access_key: "test-secret-key"
71+
})
72+
73+
expected_url =
74+
"https://bedrock-runtime.#{@region}.amazonaws.com/model/#{@inference_profile_id}/invoke"
75+
76+
expect(Req, :request, fn %Req.Request{} = request ->
77+
assert request.method == :post
78+
assert URI.to_string(request.url) == expected_url
79+
80+
{:ok,
81+
%Req.Response{
82+
status: 200,
83+
body: %Response{
84+
id: "test-response",
85+
model: @inference_profile_id,
86+
context: %ReqLLM.Context{messages: []},
87+
message: %Message{
88+
role: :assistant,
89+
content: [%ContentPart{type: :text, text: "hello"}]
90+
},
91+
finish_reason: :stop,
92+
usage: @usage,
93+
stream?: false
94+
}
95+
}}
96+
end)
97+
98+
assert {:ok, "hello"} =
99+
Bedrock.completion(bedrock, [{:user, "hi"}], [])
100+
end
101+
end
102+
end

test/console/deployments/stacks_test.exs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -873,14 +873,40 @@ defmodule Console.Deployments.StacksTest do
873873
{:error, _} = Stacks.dequeue(stack)
874874
end
875875

876-
test "it will fail if the stack is currently running a pr run" do
876+
test "it will dequeue wet runs while a pr dry run is running" do
877+
stack = insert(:stack)
878+
pr = insert(:pull_request, stack: stack)
879+
insert(:stack_run, stack: stack, status: :pending, pull_request: pr, dry_run: true)
880+
:timer.sleep(1)
881+
run = insert(:stack_run, stack: stack, status: :queued)
882+
883+
{:ok, dequeued} = Stacks.dequeue(stack)
884+
885+
assert dequeued.id == run.id
886+
assert dequeued.status == :pending
887+
end
888+
889+
test "it will fail if the pr is currently running a dry run" do
877890
stack = insert(:stack)
878891
pr = insert(:pull_request, stack: stack)
879892
insert(:stack_run, stack: stack, status: :pending, pull_request: pr, dry_run: true)
880893
:timer.sleep(1)
881894
insert(:stack_run, stack: stack, status: :queued, pull_request: pr, dry_run: true)
882895

883-
{:error, _} = Stacks.dequeue(stack)
896+
{:error, _} = Stacks.dequeue(pr)
897+
end
898+
899+
test "it will dequeue dry pr runs while a wet run is running" do
900+
stack = insert(:stack)
901+
pr = insert(:pull_request, stack: stack)
902+
insert(:stack_run, stack: stack, status: :pending)
903+
:timer.sleep(1)
904+
run = insert(:stack_run, stack: stack, status: :queued, pull_request: pr, dry_run: true)
905+
906+
{:ok, dequeued} = Stacks.dequeue(pr)
907+
908+
assert dequeued.id == run.id
909+
assert dequeued.status == :pending
884910
end
885911

886912
test "it will fail if there are no runs to dequeue" do

0 commit comments

Comments
 (0)