| 1464 |
1524
|
|
"the interactive session recorded no answer"
|
| 1465 |
1525
|
|
);
|
| 1466 |
1526
|
|
}
|
|
1527
|
+ |
|
|
1528
|
+ |
// ─────────────────────────────────────────────────────────────── the ending
|
|
1529
|
+ |
//
|
|
1530
|
+ |
// The other half of issue #106. A turn that wrote itself down still reached
|
|
1531
|
+ |
// `DELETE /api/v1/threads/{id}`, which hard-codes `error_code: cancelled` and
|
|
1532
|
+ |
// the sentence "The thread was cancelled before it reported." — so a session
|
|
1533
|
+ |
// that answered correctly and exited 0 left a permanent record saying it had
|
|
1534
|
+ |
// been cancelled, and a cancelled thread cannot be resumed.
|
|
1535
|
+ |
//
|
|
1536
|
+ |
// These prove the session says which of the three things happened, that it
|
|
1537
|
+ |
// says it before anything is revoked, and — the half that matters more — that
|
|
1538
|
+ |
// nothing which failed, was interrupted, or ran out of steps can say it
|
|
1539
|
+ |
// succeeded. Recording every session as a success would be worse than
|
|
1540
|
+ |
// recording every session as a cancellation: a reader can tell that a wall of
|
|
1541
|
+ |
// cancellations is uninformative, and cannot tell a false success from a
|
|
1542
|
+ |
// true one.
|
|
1543
|
+ |
|
|
1544
|
+ |
/// A session that answered reports `succeeded`, names no error code, and is
|
|
1545
|
+ |
/// never cancelled.
|
|
1546
|
+ |
#[tokio::test]
|
|
1547
|
+ |
async fn a_session_that_answered_reports_succeeded_and_is_not_cancelled() {
|
|
1548
|
+ |
let stub = recording_stub();
|
|
1549
|
+ |
let mut session = session(Lane::OxAlpha, stub.base.clone());
|
|
1550
|
+ |
let answer = session
|
|
1551
|
+ |
.execute_turn("what does echo hello print?", |_| {})
|
|
1552
|
+ |
.await
|
|
1553
|
+ |
.expect("the turn failed");
|
|
1554
|
+ |
assert_eq!(answer, "It said hello.");
|
|
1555
|
+ |
|
|
1556
|
+ |
let spent = session.finish().await.expect("the ending failed");
|
|
1557
|
+ |
assert_eq!(spent.map(|usage| usage.total_tokens), Some(116));
|
|
1558
|
+ |
|
|
1559
|
+ |
let report = filed_report(&stub).expect("the session never said what it did");
|
|
1560
|
+ |
assert_eq!(report["status"], "succeeded");
|
|
1561
|
+ |
assert_eq!(
|
|
1562
|
+ |
report.get("error_code"),
|
|
1563
|
+ |
None,
|
|
1564
|
+ |
"a session that answered named an error code, which the server refuses \
|
|
1565
|
+ |
and this client should not be trying: {report}"
|
|
1566
|
+ |
);
|
|
1567
|
+ |
assert_eq!(
|
|
1568
|
+ |
report["report"], "It said hello.",
|
|
1569
|
+ |
"the report is not what the session answered: {report}"
|
|
1570
|
+ |
);
|
|
1571
|
+ |
// What the session counted, sent as the session's own figure. The account
|
|
1572
|
+ |
// is charged against the grant's spend, which the reply carries back.
|
|
1573
|
+ |
assert_eq!(report["usage"]["total_tokens"], 116);
|
|
1574
|
+ |
assert_eq!(report["usage"]["counted_by"], "client");
|
|
1575
|
+ |
|
|
1576
|
+ |
// Nothing was thrown away. A cancelled thread cannot be re-granted, so a
|
|
1577
|
+ |
// `DELETE` here is what made `--resume` impossible across processes.
|
|
1578
|
+ |
assert!(
|
|
1579
|
+ |
!stub
|
|
1580
|
+ |
.request_lines()
|
|
1581
|
+ |
.iter()
|
|
1582
|
+ |
.any(|line| line.starts_with("DELETE")),
|
|
1583
|
+ |
"the session cancelled the thread it had just reported on: {:?}",
|
|
1584
|
+ |
stub.request_lines()
|
|
1585
|
+ |
);
|
|
1586
|
+ |
|
|
1587
|
+ |
// The ending fires once.
|
|
1588
|
+ |
assert!(session.finish().await.unwrap().is_none());
|
|
1589
|
+ |
assert_eq!(
|
|
1590
|
+ |
stub.request_lines()
|
|
1591
|
+ |
.iter()
|
|
1592
|
+ |
.filter(|line| line.contains("/report"))
|
|
1593
|
+ |
.count(),
|
|
1594
|
+ |
1
|
|
1595
|
+ |
);
|
|
1596
|
+ |
}
|
|
1597
|
+ |
|
|
1598
|
+ |
/// The report carries the account's own credential, and is sent with a bearer
|
|
1599
|
+ |
/// token like every other owner-scoped call.
|
|
1600
|
+ |
#[tokio::test]
|
|
1601
|
+ |
async fn the_report_carries_the_accounts_credential() {
|
|
1602
|
+ |
let stub = recording_stub();
|
|
1603
|
+ |
let mut session = session(Lane::OxAlpha, stub.base.clone());
|
|
1604
|
+ |
session
|
|
1605
|
+ |
.execute_turn("what does echo hello print?", |_| {})
|
|
1606
|
+ |
.await
|
|
1607
|
+ |
.unwrap();
|
|
1608
|
+ |
session.finish().await.expect("the ending failed");
|
|
1609
|
+ |
|
|
1610
|
+ |
let reported = stub
|
|
1611
|
+ |
.requests()
|
|
1612
|
+ |
.into_iter()
|
|
1613
|
+ |
.find(|request| request.contains("/report"))
|
|
1614
|
+ |
.expect("no report was sent");
|
|
1615
|
+ |
assert!(reported.contains("Bearer oat_test"), "{reported}");
|
|
1616
|
+ |
}
|
|
1617
|
+ |
|
|
1618
|
+ |
/// A turn the proxy refused reports `failed` with a code, and never `succeeded`.
|
|
1619
|
+ |
#[tokio::test]
|
|
1620
|
+ |
async fn a_refused_turn_reports_failed_and_names_a_code() {
|
|
1621
|
+ |
let stub = start(|request, origin| {
|
|
1622
|
+ |
let line = request.lines().next().unwrap_or_default().to_string();
|
|
1623
|
+ |
if line.starts_with("POST") && line.contains("/events") {
|
|
1624
|
+ |
return appended();
|
|
1625
|
+ |
}
|
|
1626
|
+ |
if line.starts_with("POST") && line.contains("/report") {
|
|
1627
|
+ |
return filed(0);
|
|
1628
|
+ |
}
|
|
1629
|
+ |
if line.starts_with("POST /api/v1/threads") {
|
|
1630
|
+ |
return Reply::Body(200, "application/json", grant_body(origin, "ox-alpha"));
|
|
1631
|
+ |
}
|
|
1632
|
+ |
Reply::Body(
|
|
1633
|
+ |
402,
|
|
1634
|
+ |
"application/json",
|
|
1635
|
+ |
r#"{"code":"credit_exhausted","message":"nothing left"}"#.to_string(),
|
|
1636
|
+ |
)
|
|
1637
|
+ |
});
|
|
1638
|
+ |
|
|
1639
|
+ |
let mut session = session(Lane::OxAlpha, stub.base.clone());
|
|
1640
|
+ |
session
|
|
1641
|
+ |
.execute_turn("do something", |_| {})
|
|
1642
|
+ |
.await
|
|
1643
|
+ |
.expect_err("a refused proxy returned success");
|
|
1644
|
+ |
session.finish().await.expect("the ending failed");
|
|
1645
|
+ |
|
|
1646
|
+ |
let report = filed_report(&stub).expect("the session never said what it did");
|
|
1647
|
+ |
assert_eq!(
|
|
1648
|
+ |
report["status"], "failed",
|
|
1649
|
+ |
"a turn the proxy refused was filed as something else: {report}"
|
|
1650
|
+ |
);
|
|
1651
|
+ |
assert_eq!(report["error_code"], "provider_failed");
|
|
1652
|
+ |
let why = report["report"].as_str().unwrap_or_default();
|
|
1653
|
+ |
assert!(
|
|
1654
|
+ |
why.contains("402") && why.contains("credit_exhausted"),
|
|
1655
|
+ |
"the report does not say what refused the turn: {why}"
|
|
1656
|
+ |
);
|
|
1657
|
+ |
}
|
|
1658
|
+ |
|
|
1659
|
+ |
/// A turn that spent its whole step budget reports `max_steps`, not an answer
|
|
1660
|
+ |
/// it never produced.
|
|
1661
|
+ |
#[tokio::test]
|
|
1662
|
+ |
async fn a_turn_that_runs_out_of_steps_reports_max_steps() {
|
|
1663
|
+ |
let stub = start(|request, origin| {
|
|
1664
|
+ |
let line = request.lines().next().unwrap_or_default().to_string();
|
|
1665
|
+ |
if line.starts_with("POST") && line.contains("/events") {
|
|
1666
|
+ |
return appended();
|
|
1667
|
+ |
}
|
|
1668
|
+ |
if line.starts_with("POST") && line.contains("/report") {
|
|
1669
|
+ |
return filed(0);
|
|
1670
|
+ |
}
|
|
1671
|
+ |
if line.starts_with("POST /api/v1/threads") {
|
|
1672
|
+ |
return Reply::Body(200, "application/json", grant_body(origin, "ox-alpha"));
|
|
1673
|
+ |
}
|
|
1674
|
+ |
// Never answers. Always asks for another tool.
|
|
1675
|
+ |
Reply::Sse(
|
|
1676
|
+ |
vec![frame(
|
|
1677
|
+ |
serde_json::json!({"choices":[{"delta":{"tool_calls":[{
|
|
1678
|
+ |
"index": 0,
|
|
1679
|
+ |
"id": "call_loop",
|
|
1680
|
+ |
"function": {"name": "shell", "arguments": "{\"command\":\"true\"}"}
|
|
1681
|
+ |
}]}}]}),
|
|
1682
|
+ |
)],
|
|
1683
|
+ |
None,
|
|
1684
|
+ |
)
|
|
1685
|
+ |
});
|
|
1686
|
+ |
|
|
1687
|
+ |
let mut session = session(Lane::OxAlpha, stub.base.clone());
|
|
1688
|
+ |
session
|
|
1689
|
+ |
.execute_turn("loop forever", |_| {})
|
|
1690
|
+ |
.await
|
|
1691
|
+ |
.expect_err("a turn with no answer returned one");
|
|
1692
|
+ |
session.finish().await.expect("the ending failed");
|
|
1693
|
+ |
|
|
1694
|
+ |
let report = filed_report(&stub).expect("the session never said what it did");
|
|
1695
|
+ |
assert_eq!(report["status"], "failed");
|
|
1696
|
+ |
assert_eq!(report["error_code"], "max_steps");
|
|
1697
|
+ |
assert!(
|
|
1698
|
+ |
report["report"]
|
|
1699
|
+ |
.as_str()
|
|
1700
|
+ |
.unwrap_or_default()
|
|
1701
|
+ |
.contains("tool steps"),
|
|
1702
|
+ |
"the report does not name the budget: {report}"
|
|
1703
|
+ |
);
|
|
1704
|
+ |
}
|
|
1705
|
+ |
|
|
1706
|
+ |
/// A reply that broke mid-stream reports `stream_broken`. Half an answer is
|
|
1707
|
+ |
/// not an answer.
|
|
1708
|
+ |
#[tokio::test]
|
|
1709
|
+ |
async fn a_broken_stream_reports_that_the_reply_never_finished() {
|
|
1710
|
+ |
let stub = start(|request, origin| {
|
|
1711
|
+ |
let line = request.lines().next().unwrap_or_default().to_string();
|
|
1712
|
+ |
if line.starts_with("POST") && line.contains("/events") {
|
|
1713
|
+ |
return appended();
|
|
1714
|
+ |
}
|
|
1715
|
+ |
if line.starts_with("POST") && line.contains("/report") {
|
|
1716
|
+ |
return filed(0);
|
|
1717
|
+ |
}
|
|
1718
|
+ |
if line.starts_with("POST /api/v1/threads") {
|
|
1719
|
+ |
return Reply::Body(200, "application/json", grant_body(origin, "ox-alpha"));
|
|
1720
|
+ |
}
|
|
1721
|
+ |
// A frame, then the socket goes without `[DONE]` and without the
|
|
1722
|
+ |
// declared body ever finishing.
|
|
1723
|
+ |
Reply::Truncated(frame(
|
|
1724
|
+ |
serde_json::json!({"choices":[{"delta":{"content":"PO"}}]}),
|
|
1725
|
+ |
))
|
|
1726
|
+ |
});
|
|
1727
|
+ |
|
|
1728
|
+ |
let mut session = session(Lane::OxAlpha, stub.base.clone());
|
|
1729
|
+ |
let failure = session
|
|
1730
|
+ |
.execute_turn("say pong", |_| {})
|
|
1731
|
+ |
.await
|
|
1732
|
+ |
.expect_err("half a reply was returned as an answer");
|
|
1733
|
+ |
assert!(
|
|
1734
|
+ |
failure.to_string().contains("mid-stream"),
|
|
1735
|
+ |
"the caller was told something else: {failure}"
|
|
1736
|
+ |
);
|
|
1737
|
+ |
session.finish().await.expect("the ending failed");
|
|
1738
|
+ |
|
|
1739
|
+ |
let report = filed_report(&stub).expect("the session never said what it did");
|
|
1740
|
+ |
assert_eq!(
|
|
1741
|
+ |
report["status"], "failed",
|
|
1742
|
+ |
"a reply that never finished was filed as an answer: {report}"
|
|
1743
|
+ |
);
|
|
1744
|
+ |
assert_eq!(report["error_code"], "stream_broken");
|
|
1745
|
+ |
}
|
|
1746
|
+ |
|
|
1747
|
+ |
/// A session stopped mid-turn reports `cancelled` with `interrupted`, and
|
|
1748
|
+ |
/// cannot inherit the last finished turn's success.
|
|
1749
|
+ |
///
|
|
1750
|
+ |
/// This is the Ctrl-C shape: `oa delegate` cancels a child by dropping its
|
|
1751
|
+ |
/// turn future, which never reaches the turn's own failure path.
|
|
1752
|
+ |
#[tokio::test]
|
|
1753
|
+ |
async fn an_interrupted_session_reports_cancelled_and_says_it_was_interrupted() {
|
|
1754
|
+ |
let stub = recording_stub();
|
|
1755
|
+ |
let mut session = session(Lane::OxAlpha, stub.base.clone());
|
|
1756
|
+ |
// A turn that answered first, so a stale success is available to inherit.
|
|
1757
|
+ |
session
|
|
1758
|
+ |
.execute_turn("what does echo hello print?", |_| {})
|
|
1759
|
+ |
.await
|
|
1760
|
+ |
.expect("the turn failed");
|
|
1761
|
+ |
assert_eq!(session.outcome().map(|o| o.status()), Some("succeeded"));
|
|
1762
|
+ |
|
|
1763
|
+ |
session.note_interruption("stopped before finishing").await;
|
|
1764
|
+ |
session.finish().await.expect("the ending failed");
|
|
1765
|
+ |
|
|
1766
|
+ |
let report = filed_report(&stub).expect("the session never said what it did");
|
|
1767
|
+ |
assert_eq!(
|
|
1768
|
+ |
report["status"], "cancelled",
|
|
1769
|
+ |
"an interrupted session was filed as something else: {report}"
|
|
1770
|
+ |
);
|
|
1771
|
+ |
assert_eq!(report["error_code"], "interrupted");
|
|
1772
|
+ |
assert!(
|
|
1773
|
+ |
report["report"]
|
|
1774
|
+ |
.as_str()
|
|
1775
|
+ |
.unwrap_or_default()
|
|
1776
|
+ |
.contains("stopped before finishing"),
|
|
1777
|
+ |
"{report}"
|
|
1778
|
+ |
);
|
|
1779
|
+ |
}
|
|
1780
|
+ |
|
|
1781
|
+ |
/// A turn dropped while it was still running reports as interrupted, not as
|
|
1782
|
+ |
/// whatever the previous turn did.
|
|
1783
|
+ |
///
|
|
1784
|
+ |
/// The session's standing outcome is an interruption for as long as a turn is
|
|
1785
|
+ |
/// in flight, so a process that quits mid-turn cannot file the last finished
|
|
1786
|
+ |
/// turn's answer as this session's ending.
|
|
1787
|
+ |
#[tokio::test]
|
|
1788
|
+ |
async fn a_turn_dropped_while_it_ran_does_not_report_the_previous_turns_success() {
|
|
1789
|
+ |
let stub = start(|request, origin| {
|
|
1790
|
+ |
let line = request.lines().next().unwrap_or_default().to_string();
|
|
1791
|
+ |
if line.starts_with("POST") && line.contains("/events") {
|
|
1792
|
+ |
return appended();
|
|
1793
|
+ |
}
|
|
1794
|
+ |
if line.starts_with("POST") && line.contains("/report") {
|
|
1795
|
+ |
return filed(0);
|
|
1796
|
+ |
}
|
|
1797
|
+ |
if line.starts_with("POST /api/v1/threads") {
|
|
1798
|
+ |
return Reply::Body(200, "application/json", grant_body(origin, "ox-alpha"));
|
|
1799
|
+ |
}
|
|
1800
|
+ |
// The first turn answers at once. The second is held open long enough
|
|
1801
|
+ |
// to be dropped part way through.
|
|
1802
|
+ |
if request.contains("\"content\":\"second\"") {
|
|
1803
|
+ |
return Reply::Sse(
|
|
1804
|
+ |
vec![
|
|
1805
|
+ |
frame(serde_json::json!({"choices":[{"delta":{"content":"…"}}]})),
|
|
1806
|
+ |
frame(serde_json::json!({"choices":[{"delta":{"content":"never"}}]})),
|
|
1807
|
+ |
],
|
|
1808
|
+ |
Some((1, Duration::from_secs(30))),
|
|
1809
|
+ |
);
|
|
1810
|
+ |
}
|
|
1811
|
+ |
Reply::Sse(
|
|
1812
|
+ |
vec![frame(
|
|
1813
|
+ |
serde_json::json!({"choices":[{"delta":{"content":"first"}}]}),
|
|
1814
|
+ |
)],
|
|
1815
|
+ |
None,
|
|
1816
|
+ |
)
|
|
1817
|
+ |
});
|
|
1818
|
+ |
|
|
1819
|
+ |
let mut session = session(Lane::OxAlpha, stub.base.clone());
|
|
1820
|
+ |
let answer = session.execute_turn("one", |_| {}).await.expect("turn one");
|
|
1821
|
+ |
assert_eq!(answer, "first");
|
|
1822
|
+ |
assert_eq!(session.outcome().map(|o| o.status()), Some("succeeded"));
|
|
1823
|
+ |
|
|
1824
|
+ |
// Drop the second turn part way through, exactly as quitting does.
|
|
1825
|
+ |
let dropped = tokio::time::timeout(
|
|
1826
|
+ |
Duration::from_millis(400),
|
|
1827
|
+ |
session.execute_turn("second", |_| {}),
|
|
1828
|
+ |
)
|
|
1829
|
+ |
.await;
|
|
1830
|
+ |
assert!(
|
|
1831
|
+ |
dropped.is_err(),
|
|
1832
|
+ |
"the held turn returned; the stub answered"
|
|
1833
|
+ |
);
|
|
1834
|
+ |
|
|
1835
|
+ |
assert_eq!(
|
|
1836
|
+ |
session.outcome().map(|o| o.status()),
|
|
1837
|
+ |
Some("cancelled"),
|
|
1838
|
+ |
"a session dropped mid-turn kept the previous turn's outcome"
|
|
1839
|
+ |
);
|
|
1840
|
+ |
session.finish().await.expect("the ending failed");
|
|
1841
|
+ |
let report = filed_report(&stub).expect("the session never said what it did");
|
|
1842
|
+ |
assert_eq!(report["status"], "cancelled");
|
|
1843
|
+ |
assert_eq!(report["error_code"], "interrupted");
|
|
1844
|
+ |
assert_ne!(report["report"], "first");
|
|
1845
|
+ |
}
|
|
1846
|
+ |
|
|
1847
|
+ |
/// A session that held a thread and never ran a turn does not claim it
|
|
1848
|
+ |
/// answered.
|
|
1849
|
+ |
#[tokio::test]
|
|
1850
|
+ |
async fn a_thread_no_turn_ran_on_reports_that_no_turn_ran() {
|
|
1851
|
+ |
let stub = start(|request, origin| {
|
|
1852
|
+ |
let line = request.lines().next().unwrap_or_default().to_string();
|
|
1853
|
+ |
if line.starts_with("POST") && line.contains("/report") {
|
|
1854
|
+ |
return filed(0);
|
|
1855
|
+ |
}
|
|
1856
|
+ |
if line.starts_with("POST /api/v1/threads/") && line.contains("/grants") {
|
|
1857
|
+ |
return Reply::Body(200, "application/json", grant_body(origin, "ox-alpha"));
|
|
1858
|
+ |
}
|
|
1859
|
+ |
Reply::Body(200, "application/json", "{}".to_string())
|
|
1860
|
+ |
});
|
|
1861
|
+ |
|
|
1862
|
+ |
let mut session = session(Lane::OxAlpha, stub.base.clone());
|
|
1863
|
+ |
session
|
|
1864
|
+ |
.adopt_thread("th_test")
|
|
1865
|
+ |
.await
|
|
1866
|
+ |
.expect("the thread was not adopted");
|
|
1867
|
+ |
assert!(session.outcome().is_none());
|
|
1868
|
+ |
session.finish().await.expect("the ending failed");
|
|
1869
|
+ |
|
|
1870
|
+ |
let report = filed_report(&stub).expect("the session never said what it did");
|
|
1871
|
+ |
assert_eq!(report["status"], "failed");
|
|
1872
|
+ |
assert_eq!(report["error_code"], "no_turn");
|
|
1873
|
+ |
}
|
|
1874
|
+ |
|
|
1875
|
+ |
/// A deployment without the report route still has its thread ended, and says
|
|
1876
|
+ |
/// so rather than swallowing it.
|
|
1877
|
+ |
///
|
|
1878
|
+ |
/// A thread left open holds its grant's remaining budget (#107), so the
|
|
1879
|
+ |
/// refusal falls back to the disposal — and the report is sent first, which is
|
|
1880
|
+ |
/// the only place both requests appear in one run.
|
|
1881
|
+ |
#[tokio::test]
|
|
1882
|
+ |
async fn a_refused_report_still_ends_the_thread_and_is_reported_to_the_reader() {
|
|
1883
|
+ |
let stub = start(|request, origin| {
|
|
1884
|
+ |
let line = request.lines().next().unwrap_or_default().to_string();
|
|
1885
|
+ |
if line.starts_with("POST") && line.contains("/events") {
|
|
1886
|
+ |
return appended();
|
|
1887
|
+ |
}
|
|
1888
|
+ |
if line.starts_with("POST") && line.contains("/report") {
|
|
1889
|
+ |
return Reply::Body(404, "text/plain", "Not Found".to_string());
|
|
1890
|
+ |
}
|
|
1891
|
+ |
if line.starts_with("POST /api/v1/threads") {
|
|
1892
|
+ |
return Reply::Body(200, "application/json", grant_body(origin, "ox-alpha"));
|
|
1893
|
+ |
}
|
|
1894
|
+ |
if line.starts_with("DELETE /api/v1/threads/") {
|
|
1895
|
+ |
return revoked(116);
|
|
1896
|
+ |
}
|
|
1897
|
+ |
Reply::Sse(
|
|
1898
|
+ |
vec![frame(
|
|
1899
|
+ |
serde_json::json!({"choices":[{"delta":{"content":"ok"}}]}),
|
|
1900
|
+ |
)],
|
|
1901
|
+ |
None,
|
|
1902
|
+ |
)
|
|
1903
|
+ |
});
|
|
1904
|
+ |
|
|
1905
|
+ |
let mut session = session(Lane::OxAlpha, stub.base.clone());
|
|
1906
|
+ |
session.execute_turn("say ok", |_| {}).await.unwrap();
|
|
1907
|
+ |
let spent = session
|
|
1908
|
+ |
.finish()
|
|
1909
|
+ |
.await
|
|
1910
|
+ |
.expect("a refused report left the thread open");
|
|
1911
|
+ |
assert_eq!(spent.map(|usage| usage.total_tokens), Some(116));
|
|
1912
|
+ |
|
|
1913
|
+ |
let lines = stub.request_lines();
|
|
1914
|
+ |
let attempted = lines
|
|
1915
|
+ |
.iter()
|
|
1916
|
+ |
.position(|line| line.contains("/report"))
|
|
1917
|
+ |
.expect("no report was attempted");
|
|
1918
|
+ |
let revocation = lines
|
|
1919
|
+ |
.iter()
|
|
1920
|
+ |
.position(|line| line.starts_with("DELETE"))
|
|
1921
|
+ |
.expect("the thread was left open");
|
|
1922
|
+ |
assert!(
|
|
1923
|
+ |
attempted < revocation,
|
|
1924
|
+ |
"the thread was cancelled before it tried to report: {lines:?}"
|
|
1925
|
+ |
);
|
|
1926
|
+ |
assert!(
|
|
1927
|
+ |
session
|
|
1928
|
+ |
.record_failures
|
|
1929
|
+ |
.iter()
|
|
1930
|
+ |
.any(|failure| failure.contains("404") && failure.contains("report")),
|
|
1931
|
+ |
"the refused report was swallowed: {:?}",
|
|
1932
|
+ |
session.record_failures
|
|
1933
|
+ |
);
|
|
1934
|
+ |
}
|
|
1935
|
+ |
|
|
1936
|
+ |
/// The local lane has no thread, so it reports nothing and fails at nothing.
|
|
1937
|
+ |
#[tokio::test]
|
|
1938
|
+ |
async fn a_session_with_no_thread_reports_nothing() {
|
|
1939
|
+ |
let mut session = session(Lane::Local("qwen3".to_string()), DEAD.to_string());
|
|
1940
|
+ |
assert!(session
|
|
1941
|
+ |
.finish()
|
|
1942
|
+ |
.await
|
|
1943
|
+ |
.expect("no thread is not a failure")
|
|
1944
|
+ |
.is_none());
|
|
1945
|
+ |
assert!(session
|
|
1946
|
+ |
.report(openagents_cli::runtime::ThreadOutcome::succeeded(
|
|
1947
|
+ |
"anything"
|
|
1948
|
+ |
))
|
|
1949
|
+ |
.await
|
|
1950
|
+ |
.expect("no thread is not a failure")
|
|
1951
|
+ |
.is_none());
|
|
1952
|
+ |
}
|