Skip to content

Commit c2b3269

Browse files
committed
Add agent context tests.
1 parent b7785ad commit c2b3269

4 files changed

Lines changed: 88 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Test Agent Context
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
test:
10+
name: Agent Context
11+
runs-on: ubuntu-latest
12+
13+
services:
14+
ollama:
15+
image: ollama/ollama
16+
ports:
17+
- 11434:11434
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: ruby/setup-ruby@v1
22+
with:
23+
bundler-cache: true
24+
25+
- name: Pull Model
26+
run: bundle exec bake async:ollama:pull
27+
28+
- name: Run tests
29+
timeout-minutes: 30
30+
run: bundle exec sus test/.agent/context

agent.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ This guide explains how to test and monitor documentation coverage in your Ruby
3030

3131
This guide covers documentation practices and pragmas supported by the Decode gem for documenting Ruby code. These pragmas provide structured documentation that can be parsed and used to generate A...
3232

33+
#### [Setting Up RBS Types and Steep Type Checking for Ruby Gems](.context/decode/types.md)
34+
35+
This guide covers the process for establishing robust type checking in Ruby gems using RBS and Steep, focusing on automated generation from source documentation and proper validation.
36+
3337
### sus
3438

3539
A fast and scalable test runner.
@@ -45,3 +49,15 @@ There are two types of mocking in sus: `receive` and `mock`. The `receive` match
4549
#### [Shared Test Behaviors and Fixtures](.context/sus/shared.md)
4650

4751
Sus provides shared test contexts which can be used to define common behaviours or tests that can be reused across one or more test files.
52+
53+
### sus-fixtures-agent-context
54+
55+
Test fixtures for running in Async.
56+
57+
#### [Getting Started](.context/sus-fixtures-agent-context/getting-started.md)
58+
59+
This guide explains how to use the `sus-fixtures-agent-context` gem to test agent contexts.
60+
61+
#### [GitHub Actions](.context/sus-fixtures-agent-context/github-actions.md)
62+
63+
This guide explains how to integrate the `sus-fixtures-agent-context` gem with GitHub Actions for testing agent contexts.

gems.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
gem "sus-fixtures-console"
3939
gem "sus-fixtures-time"
4040
gem "sus-fixtures-benchmark"
41+
gem "sus-fixtures-agent-context"
4142

4243
gem "bake-test"
4344
gem "bake-test-external"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
require "sus/fixtures/async"
3+
require "sus/fixtures/agent/context"
4+
5+
describe "context/thread-safety.md" do
6+
include Sus::Fixtures::Agent::Context
7+
8+
let(:context_path) {File.expand_path("../../..", __dir__)}
9+
let(:path) {File.join(context_path, subject)}
10+
11+
it "can be used to test thread safety" do
12+
with_agent_context(path) do |context|
13+
response = context.call(<<~PROMPT)
14+
Is the following code thread-safe? Start your response with "yes" or "no".
15+
16+
```ruby
17+
while @pool.busy?
18+
@pool.wait
19+
end
20+
```
21+
PROMPT
22+
23+
expect(response).to be =~ /\Ano/i
24+
end
25+
end
26+
27+
it "can be used to test thread safety" do
28+
with_agent_context(path) do |context|
29+
response = context.call(<<~PROMPT)
30+
Is the following code thread-safe? Start your response with "yes" or "no".
31+
32+
```ruby
33+
# array is not shared.
34+
array.sort!
35+
```
36+
PROMPT
37+
38+
expect(response).to be =~ /\Ayes/i
39+
end
40+
end
41+
end

0 commit comments

Comments
 (0)