AI agent debug代码的一个完整案例

版主: hci

回复
wdong(万事休)楼主
见习作家
见习作家
帖子互动: 92
帖子: 410
注册时间: 2023年 11月 13日 15:13

#1 AI agent debug代码的一个完整案例

帖子 wdong(万事休)楼主 »

有三方通话:user, swe1, shell

我已经提前训练了AI使用shell以及我的定制化命令。训练时我作为user和swe1对话,我没有把训练内容贴出来, 如果贴出来的话就是前面还有大概这么多邮件交互。下面的记录是全自动跑的, user和swe1背后都是gpt4o。因为训练时的user是我,所以你们看到下面的user其实算是gpt4o模仿我的口气给swe1发邮件。凡是调API时会有一个M-Cost邮件头。

这是swe-bench里最简单的案例之一。但这确实是django在github上的真实案例,以前这种都是要人fix的。

阅读方法是注意看看----分界下面的From:, To:.
AI调用shell的协议是: Subject:的内容是命令,如果邮件有body,则body的内容作为stdin。AI大致的思路是先用grep找对应的程序,找到后用aa_list显示程序内容,然后用aa_edit修改。最后用aa_test测试。测试通过我的driver会自动终止。如果测试通不过,AI会接着试别的办法,这时候往往就跑飞了. Driver会track花了多少钱,到了预定的budget就会终止循环。 像这么一个session差不多花一两毛钱。 复杂点的问题一块钱很快就花掉了。


From --------------------------------
From: user@localdomain
To: swe1@localdomain
Subject: New project
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0

We are now in a new codebase. Solve the issue as we did before.


From --------------------------------
From: swe1@localdomain
To: shell@localdomain
Subject: aa_open ./.swe/problem_statement.txt
Content-Type: text/plain
M-Model: openai/gpt-4o
M-Tokens-Input: 3196
M-Tokens-Output: 35
M-Cost: 0.00834000




From --------------------------------
From: shell@localdomain
To: swe1@localdomain
Subject: Exit Code: 0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0

--- stdout ---
current file: ./.swe/problem_statement.txt
total lines: 9
cannot scroll

From --------------------------------
From: swe1@localdomain
To: shell@localdomain
Subject: aa_list 1-9
Content-Type: text/plain
M-Model: openai/gpt-4o
M-Tokens-Input: 3290
M-Tokens-Output: 32
M-Cost: 0.00854500




From --------------------------------
From: shell@localdomain
To: swe1@localdomain
Subject: Exit Code: 0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

--- stdout ---
1|UsernameValidator allows trailing newline in usernames
2|Description
3|
4|ASCIIUsernameValidator and UnicodeUsernameValidator use the regex
5|r'^[\w.@+-]+$'
6|The intent is to only allow alphanumeric characters as well as ., @, +, =
and -. However, a little known quirk of Python regexes is that $ will also ma=
tch a trailing newline. Therefore, the user name validators will accept usern=
ames which end with a newline. You can avoid this behavior by instead using \=
A and \Z to terminate regexes. For example, the validator regex could be chan=
ged to
7|r'\A[\w.@+-]+\Z'
8|in order to reject usernames that end with a newline.
9|I am not sure how to officially post a patch, but the required change is=
trivial - using the regex above in the two validators in contrib.auth.valida=
tors.

current file: ./.swe/problem_statement.txt
total lines: 9
can scroll

From --------------------------------
From: swe1@localdomain
To: user@localdomain
Subject: Approach to Fix the Username Validator Issue
Content-Type: text/plain
M-Model: openai/gpt-4o
M-Tokens-Input: 3582
M-Tokens-Output: 225
M-Cost: 0.01120500

The issue at hand involves the `UsernameValidator` in Django which incorrectly allows trailing newlines in usernames due to the use of the `^` and `$` anchors in its regular expressions. We need to modify the regex pattern to use `\A` and `\Z` instead, to ensure trailing newlines are not allowed.

**Approach to Fix the Issue:**

1. **Identify the Validators:**
- Locate `ASCIIUsernameValidator` and `UnicodeUsernameValidator` implementations within the codebase.

2. **Update Regex Pattern:**
- Change the regex pattern from `r'^[\w.@+-]+$'` to `r'\A[\w.@+-]+\Z'` to prevent trailing newlines.

3. **Testing:**
- Run any relevant tests to ensure the changes work correctly and trailing newlines are no longer permissible.

Let's proceed by locating these validators in the codebase and making the necessary changes.

From --------------------------------
From: user@localdomain
To: swe1@localdomain
Subject:
Content-Type: text/plain
M-Model: openai/gpt-4o
M-Tokens-Input: 1687
M-Tokens-Output: 34
M-Cost: 0.00455750

Locate the relevant file to apply the changes.

From --------------------------------
From: swe1@localdomain
To: shell@localdomain
Subject: grep -r "UsernameValidator" ./django/contrib/auth/validators
Content-Type: text/plain
M-Model: openai/gpt-4o
M-Tokens-Input: 3847
M-Tokens-Output: 39
M-Cost: 0.01000750


From --------------------------------
From: shell@localdomain
To: swe1@localdomain
Subject: Exit Code: 2
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0

--- stderr ---
grep: ./django/contrib/auth/validators: No such file or directory

From --------------------------------
From: swe1@localdomain
To: shell@localdomain
Subject: grep -r "UsernameValidator" ./django/contrib/auth/
Content-Type: text/plain
M-Model: openai/gpt-4o
M-Tokens-Input: 3941
M-Tokens-Output: 39
M-Cost: 0.01024250




From --------------------------------
From: shell@localdomain
To: swe1@localdomain
Subject: Exit Code: 0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

--- stdout ---
./django/contrib/auth/models.py:from .validators import UnicodeUsernameValida=
tor
./django/contrib/auth/models.py: username_validator =3D UnicodeUsernameVal=
idator()
./django/contrib/auth/migrations/0007_alter_validators_add_error_messages.py:=
validators=3D[validators.UnicodeUsernameValidator()],
./django/contrib/auth/migrations/0008_alter_user_username_max_length.py: =
validators=3D[validators.UnicodeUsernameValidator()],
./django/contrib/auth/migrations/0004_alter_user_username_opts.py: =
validators=3D[validators.UnicodeUsernameValidator()],
./django/contrib/auth/migrations/0001_initial.py: validato=
rs=3D[validators.UnicodeUsernameValidator()],
./django/contrib/auth/validators.py:class ASCIIUsernameValidator(validators.R=
egexValidator):
./django/contrib/auth/validators.py:class UnicodeUsernameValidator(validators=
.RegexValidator):

From --------------------------------
From: swe1@localdomain
To: shell@localdomain
Subject: aa_open ./django/contrib/auth/validators.py
Content-Type: text/plain
M-Model: openai/gpt-4o
M-Tokens-Input: 4190
M-Tokens-Output: 36
M-Cost: 0.01083500




From --------------------------------
From: shell@localdomain
To: swe1@localdomain
Subject: Exit Code: 0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0

--- stdout ---
current file: ./django/contrib/auth/validators.py
total lines: 25
cannot scroll

From --------------------------------
From: swe1@localdomain
To: shell@localdomain
Subject: aa_list 1-25
Content-Type: text/plain
M-Model: openai/gpt-4o
M-Tokens-Input: 4286
M-Tokens-Output: 32
M-Cost: 0.01103500




From --------------------------------
From: shell@localdomain
To: swe1@localdomain
Subject: Exit Code: 0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

--- stdout ---
1|import re
2|
3|from django.core import validators
4|from django.utils.deconstruct import deconstructible
5|from django.utils.translation import gettext_lazy as _
6|
7|
8|@deconstructible
9|class ASCIIUsernameValidator(validators.RegexValidator):
10| regex =3D r'^[\w.@+-]+$'
11| message =3D _(
12| 'Enter a valid username. This value may contain only English let=
ters, '
13| 'numbers, and @/./+/-/_ characters.'
14| )
15| flags =3D re.ASCII
16|
17|
18|@deconstructible
19|class UnicodeUsernameValidator(validators.RegexValidator):
20| regex =3D r'^[\w.@+-]+$'
21| message =3D _(
22| 'Enter a valid username. This value may contain only letters, '
23| 'numbers, and @/./+/-/_ characters.'
24| )
25| flags =3D 0

current file: ./django/contrib/auth/validators.py
total lines: 25
can scroll

From --------------------------------
From: swe1@localdomain
To: shell@localdomain
Subject: aa_edit 10-20
Content-Type: text/plain
M-Model: openai/gpt-4o
M-Tokens-Input: 4642
M-Tokens-Output: 121
M-Cost: 0.01281500

regex = r'\A[\w.@+-]+\Z'
message = _(
'Enter a valid username. This value may contain only English letters, '
'numbers, and @/./+/-/_ characters.'
)
flags = re.ASCII


@deconstructible
class UnicodeUsernameValidator(validators.RegexValidator):
regex = r'\A[\w.@+-]+\Z'

From --------------------------------
From: shell@localdomain
To: swe1@localdomain
Subject: Exit Code: 0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0

--- stdout ---
11 lines replaced.
current file: ./django/contrib/auth/validators.py
total lines: 25
cannot scroll

From --------------------------------
From: swe1@localdomain
To: shell@localdomain
Subject: aa_test
Content-Type: text/plain
M-Model: openai/gpt-4o
M-Tokens-Input: 4827
M-Tokens-Output: 28
M-Cost: 0.01234750




From --------------------------------
From: shell@localdomain
To: swe1@localdomain
Subject: Exit Code: 0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0

--- stdout ---
0c5641a4f08f798f24001d2c1bd3bc9e5d070a873250a80be8d158a5281e4772
Congratulations! You have passed the test.

标签/Tags:
wdong(万事休)楼主
见习作家
见习作家
帖子互动: 92
帖子: 410
注册时间: 2023年 11月 13日 15:13

#2 Re: AI agent debug代码的一个完整案例

帖子 wdong(万事休)楼主 »

aa_list 100-200这个命令会显示当前文件的100-200行给AI看。注意是带行号的,便于AI引用。然后如果要编辑用aa_edit 20-40,把 20-40行换成想要的内容。但是即便如此,目前还是会碰到串行的情况。Princeton的做法是加入pyflakes/pylint,如果发现编辑结果有语法错误直接反馈给agent。设计一个更好的协议能够降低AI出错的可能性。
头像
TheMatrix
论坛支柱
论坛支柱
2024年度优秀版主
TheMatrix 的博客
帖子互动: 264
帖子: 13239
注册时间: 2022年 7月 26日 00:35

#3 Re: AI agent debug代码的一个完整案例

帖子 TheMatrix »

wdong 写了: 2025年 2月 25日 13:57
From --------------------------------
From: user@localdomain
To: swe1@localdomain
Subject:
Content-Type: text/plain
M-Model: openai/gpt-4o
M-Tokens-Input: 1687
M-Tokens-Output: 34
M-Cost: 0.00455750

Locate the relevant file to apply the changes.

From --------------------------------
From: swe1@localdomain
To: shell@localdomain
Subject: grep -r "UsernameValidator" ./django/contrib/auth/validators
Content-Type: text/plain
M-Model: openai/gpt-4o
M-Tokens-Input: 3847
M-Tokens-Output: 39
M-Cost: 0.01000750
请看引用的这两个email。

1,第一封email是你发给swe的,email body中的那句话是你手工输入的吗?

2,第二封信中的subject中的命令,是swe收到你的第一封email,然后调用gpt4o,产生的命令行。对吗?
wdong(万事休)楼主
见习作家
见习作家
帖子互动: 92
帖子: 410
注册时间: 2023年 11月 13日 15:13

#4 Re: AI agent debug代码的一个完整案例

帖子 wdong(万事休)楼主 »

TheMatrix 写了: 2025年 2月 25日 21:22 请看引用的这两个email。

1,第一封email是你发给swe的,email body中的那句话是你手工输入的吗?

2,第二封信中的subject中的命令,是swe收到你的第一封email,然后调用gpt4o,产生的命令行。对吗?
1. 这句话也是gpt4o产生的。整个邮件包括邮件头都是gpt4o产生的,不过格式转换过程中可能加减了部分邮件头。因为是自动模式,本来应该我回复的地方也都交给了gpt。调gpt时的输入是我的视角看到的过去收发的邮件,所以gpt会模拟我的行为。

2. 对。

我调gpt时没有别的协议了。gpt生成的就是完整的连头带尾的邮件。
头像
TheMatrix
论坛支柱
论坛支柱
2024年度优秀版主
TheMatrix 的博客
帖子互动: 264
帖子: 13239
注册时间: 2022年 7月 26日 00:35

#5 Re: AI agent debug代码的一个完整案例

帖子 TheMatrix »

wdong 写了: 2025年 2月 25日 21:53 1. 这句话也是gpt4o产生的。整个邮件包括邮件头都是gpt4o产生的,不过格式转换过程中可能加减了部分邮件头。因为是自动模式,本来应该我回复的地方也都交给了gpt。调gpt时的输入是我的视角看到的过去收发的邮件,所以gpt会模拟我的行为。

2. 对。

我调gpt时没有别的协议了。gpt生成的就是完整的连头带尾的邮件。
请看引用中highlight这句话。

这封email(body是 “Locate the relevant file to apply the changes.”)也是gpt4o产生的。你调用gpt4o以产生这封邮件的时候,输入的是过去各方收发的全部邮件?包括swe和shell之间的交互以及全部的shell返回的stdout?
wdong(万事休)楼主
见习作家
见习作家
帖子互动: 92
帖子: 410
注册时间: 2023年 11月 13日 15:13

#6 Re: AI agent debug代码的一个完整案例

帖子 wdong(万事休)楼主 »

TheMatrix 写了: 2025年 2月 25日 22:25 请看引用中highlight这句话。

这封email(body是 “Locate the relevant file to apply the changes.”)也是gpt4o产生的。你调用gpt4o以产生这封邮件的时候,输入的是过去各方收发的全部邮件?包括swe和shell之间的交互以及全部的shell返回的stdout?
邮箱地址是agent的ID. 如果地址出现在了From或者To里,则该邮件对该地址/agent可见(这个邮件会出现在它的收件箱或者发件箱里)。任意给定一个地址,我们可以把所有对该地址可见的邮件捞出来,也就是该地址收件箱和发件箱的总和。捞出来以后排个序。如果最后一个邮件是发出去的,则不需要inference。如果是收到的,则需要调用inference产生一个回复。

User看不到swe1和shell之间的通信,所以不包括。

我贴的是系统中所有的邮件。可以以此把每个地址的收件箱和发件箱重构出来。
头像
TheMatrix
论坛支柱
论坛支柱
2024年度优秀版主
TheMatrix 的博客
帖子互动: 264
帖子: 13239
注册时间: 2022年 7月 26日 00:35

#7 Re: AI agent debug代码的一个完整案例

帖子 TheMatrix »

wdong 写了: 2025年 2月 25日 22:58 邮箱地址是agent的ID. 如果地址出现在了From或者To里,则该邮件对该地址/agent可见(这个邮件会出现在它的收件箱或者发件箱里)。任意给定一个地址,我们可以把所有对该地址可见的邮件捞出来,也就是该地址收件箱和发件箱的总和。捞出来以后排个序。如果最后一个邮件是发出去的,则不需要inference。如果是收到的,则需要调用inference产生一个回复。

User看不到swe1和shell之间的通信,所以不包括。

我贴的是系统中所有的邮件。可以以此把每个地址的收件箱和发件箱重构出来。
谢谢。

为什么说“所以gpt会模拟我的行为”?
调gpt时的输入是我的视角看到的过去收发的邮件,所以gpt会模拟我的行为
wdong(万事休)楼主
见习作家
见习作家
帖子互动: 92
帖子: 410
注册时间: 2023年 11月 13日 15:13

#8 Re: AI agent debug代码的一个完整案例

帖子 wdong(万事休)楼主 »

TheMatrix 写了: 2025年 2月 26日 07:58 谢谢。

为什么说“所以gpt会模拟我的行为”?
因为in-context learning. Prompt里user是这么说话的,那么它下次以user的身份说话也会尽量这么说。
头像
mmking(上水)
论坛支柱
论坛支柱
帖子互动: 1269
帖子: 9184
注册时间: 2023年 1月 25日 05:10

#9 Re: AI agent debug代码的一个完整案例

帖子 mmking(上水) »

太长了,摘要一下干了啥
wdong 写了: 2025年 2月 25日 13:57 有三方通话:user, swe1, shell

我已经提前训练了AI使用shell以及我的定制化命令。训练时我作为user和swe1对话,我没有把训练内容贴出来, 如果贴出来的话就是前面还有大概这么多邮件交互。下面的记录是全自动跑的, user和swe1背后都是gpt4o。因为训练时的user是我,所以你们看到下面的user其实算是gpt4o模仿我的口气给swe1发邮件。凡是调API时会有一个M-Cost邮件头。

这是swe-bench里最简单的案例之一。但这确实是django在github上的真实案例,以前这种都是要人fix的。

阅读方法是注意看看----分界下面的From:, To:.
AI调用shell的协议是: Subject:的内容是命令,如果邮件有body,则body的内容作为stdin。AI大致的思路是先用grep找对应的程序,找到后用aa_list显示程序内容,然后用aa_edit修改。最后用aa_test测试。测试通过我的driver会自动终止。如果测试通不过,AI会接着试别的办法,这时候往往就跑飞了. Driver会track花了多少钱,到了预定的budget就会终止循环。 像这么一个session差不多花一两毛钱。 复杂点的问题一块钱很快就花掉了。


From --------------------------------
From: user@localdomain
To: swe1@localdomain
Subject: New project
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0

We are now in a new codebase. Solve the issue as we did before.


From --------------------------------
From: swe1@localdomain
To: shell@localdomain
Subject: aa_open ./.swe/problem_statement.txt
Content-Type: text/plain
M-Model: openai/gpt-4o
M-Tokens-Input: 3196
M-Tokens-Output: 35
M-Cost: 0.00834000




From --------------------------------
From: shell@localdomain
To: swe1@localdomain
Subject: Exit Code: 0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0

--- stdout ---
current file: ./.swe/problem_statement.txt
total lines: 9
cannot scroll

From --------------------------------
From: swe1@localdomain
To: shell@localdomain
Subject: aa_list 1-9
Content-Type: text/plain
M-Model: openai/gpt-4o
M-Tokens-Input: 3290
M-Tokens-Output: 32
M-Cost: 0.00854500




From --------------------------------
From: shell@localdomain
To: swe1@localdomain
Subject: Exit Code: 0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

--- stdout ---
1|UsernameValidator allows trailing newline in usernames
2|Description
3|
4|ASCIIUsernameValidator and UnicodeUsernameValidator use the regex
5|r'^[\w.@+-]+$'
6|The intent is to only allow alphanumeric characters as well as ., @, +, =
and -. However, a little known quirk of Python regexes is that $ will also ma=
tch a trailing newline. Therefore, the user name validators will accept usern=
ames which end with a newline. You can avoid this behavior by instead using \=
A and \Z to terminate regexes. For example, the validator regex could be chan=
ged to
7|r'\A[\w.@+-]+\Z'
8|in order to reject usernames that end with a newline.
9|I am not sure how to officially post a patch, but the required change is=
trivial - using the regex above in the two validators in contrib.auth.valida=
tors.

current file: ./.swe/problem_statement.txt
total lines: 9
can scroll

From --------------------------------
From: swe1@localdomain
To: user@localdomain
Subject: Approach to Fix the Username Validator Issue
Content-Type: text/plain
M-Model: openai/gpt-4o
M-Tokens-Input: 3582
M-Tokens-Output: 225
M-Cost: 0.01120500

The issue at hand involves the `UsernameValidator` in Django which incorrectly allows trailing newlines in usernames due to the use of the `^` and `$` anchors in its regular expressions. We need to modify the regex pattern to use `\A` and `\Z` instead, to ensure trailing newlines are not allowed.

**Approach to Fix the Issue:**

1. **Identify the Validators:**
- Locate `ASCIIUsernameValidator` and `UnicodeUsernameValidator` implementations within the codebase.

2. **Update Regex Pattern:**
- Change the regex pattern from `r'^[\w.@+-]+$'` to `r'\A[\w.@+-]+\Z'` to prevent trailing newlines.

3. **Testing:**
- Run any relevant tests to ensure the changes work correctly and trailing newlines are no longer permissible.

Let's proceed by locating these validators in the codebase and making the necessary changes.

From --------------------------------
From: user@localdomain
To: swe1@localdomain
Subject:
Content-Type: text/plain
M-Model: openai/gpt-4o
M-Tokens-Input: 1687
M-Tokens-Output: 34
M-Cost: 0.00455750

Locate the relevant file to apply the changes.

From --------------------------------
From: swe1@localdomain
To: shell@localdomain
Subject: grep -r "UsernameValidator" ./django/contrib/auth/validators
Content-Type: text/plain
M-Model: openai/gpt-4o
M-Tokens-Input: 3847
M-Tokens-Output: 39
M-Cost: 0.01000750


From --------------------------------
From: shell@localdomain
To: swe1@localdomain
Subject: Exit Code: 2
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0

--- stderr ---
grep: ./django/contrib/auth/validators: No such file or directory

From --------------------------------
From: swe1@localdomain
To: shell@localdomain
Subject: grep -r "UsernameValidator" ./django/contrib/auth/
Content-Type: text/plain
M-Model: openai/gpt-4o
M-Tokens-Input: 3941
M-Tokens-Output: 39
M-Cost: 0.01024250




From --------------------------------
From: shell@localdomain
To: swe1@localdomain
Subject: Exit Code: 0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

--- stdout ---
./django/contrib/auth/models.py:from .validators import UnicodeUsernameValida=
tor
./django/contrib/auth/models.py: username_validator =3D UnicodeUsernameVal=
idator()
./django/contrib/auth/migrations/0007_alter_validators_add_error_messages.py:=
validators=3D[validators.UnicodeUsernameValidator()],
./django/contrib/auth/migrations/0008_alter_user_username_max_length.py: =
validators=3D[validators.UnicodeUsernameValidator()],
./django/contrib/auth/migrations/0004_alter_user_username_opts.py: =
validators=3D[validators.UnicodeUsernameValidator()],
./django/contrib/auth/migrations/0001_initial.py: validato=
rs=3D[validators.UnicodeUsernameValidator()],
./django/contrib/auth/validators.py:class ASCIIUsernameValidator(validators.R=
egexValidator):
./django/contrib/auth/validators.py:class UnicodeUsernameValidator(validators=
.RegexValidator):

From --------------------------------
From: swe1@localdomain
To: shell@localdomain
Subject: aa_open ./django/contrib/auth/validators.py
Content-Type: text/plain
M-Model: openai/gpt-4o
M-Tokens-Input: 4190
M-Tokens-Output: 36
M-Cost: 0.01083500




From --------------------------------
From: shell@localdomain
To: swe1@localdomain
Subject: Exit Code: 0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0

--- stdout ---
current file: ./django/contrib/auth/validators.py
total lines: 25
cannot scroll

From --------------------------------
From: swe1@localdomain
To: shell@localdomain
Subject: aa_list 1-25
Content-Type: text/plain
M-Model: openai/gpt-4o
M-Tokens-Input: 4286
M-Tokens-Output: 32
M-Cost: 0.01103500




From --------------------------------
From: shell@localdomain
To: swe1@localdomain
Subject: Exit Code: 0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

--- stdout ---
1|import re
2|
3|from django.core import validators
4|from django.utils.deconstruct import deconstructible
5|from django.utils.translation import gettext_lazy as _
6|
7|
8|@deconstructible
9|class ASCIIUsernameValidator(validators.RegexValidator):
10| regex =3D r'^[\w.@+-]+$'
11| message =3D _(
12| 'Enter a valid username. This value may contain only English let=
ters, '
13| 'numbers, and @/./+/-/_ characters.'
14| )
15| flags =3D re.ASCII
16|
17|
18|@deconstructible
19|class UnicodeUsernameValidator(validators.RegexValidator):
20| regex =3D r'^[\w.@+-]+$'
21| message =3D _(
22| 'Enter a valid username. This value may contain only letters, '
23| 'numbers, and @/./+/-/_ characters.'
24| )
25| flags =3D 0

current file: ./django/contrib/auth/validators.py
total lines: 25
can scroll

From --------------------------------
From: swe1@localdomain
To: shell@localdomain
Subject: aa_edit 10-20
Content-Type: text/plain
M-Model: openai/gpt-4o
M-Tokens-Input: 4642
M-Tokens-Output: 121
M-Cost: 0.01281500

regex = r'\A[\w.@+-]+\Z'
message = _(
'Enter a valid username. This value may contain only English letters, '
'numbers, and @/./+/-/_ characters.'
)
flags = re.ASCII


@deconstructible
class UnicodeUsernameValidator(validators.RegexValidator):
regex = r'\A[\w.@+-]+\Z'

From --------------------------------
From: shell@localdomain
To: swe1@localdomain
Subject: Exit Code: 0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0

--- stdout ---
11 lines replaced.
current file: ./django/contrib/auth/validators.py
total lines: 25
cannot scroll

From --------------------------------
From: swe1@localdomain
To: shell@localdomain
Subject: aa_test
Content-Type: text/plain
M-Model: openai/gpt-4o
M-Tokens-Input: 4827
M-Tokens-Output: 28
M-Cost: 0.01234750




From --------------------------------
From: shell@localdomain
To: swe1@localdomain
Subject: Exit Code: 0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0

--- stdout ---
0c5641a4f08f798f24001d2c1bd3bc9e5d070a873250a80be8d158a5281e4772
Congratulations! You have passed the test.
这个麦当劳多少钱? 嗷呜嗷呜炸鸡盘😄viewtopic.php?t=829802

凡所有相,皆是虚妄

图片
头像
TheMatrix
论坛支柱
论坛支柱
2024年度优秀版主
TheMatrix 的博客
帖子互动: 264
帖子: 13239
注册时间: 2022年 7月 26日 00:35

#10 Re: AI agent debug代码的一个完整案例

帖子 TheMatrix »

wdong 写了: 2025年 2月 26日 08:22 因为in-context learning. Prompt里user是这么说话的,那么它下次以user的身份说话也会尽量这么说。
好的。谢谢!
forecasting
著名点评
著名点评
帖子互动: 295
帖子: 4093
注册时间: 2023年 4月 17日 08:26

#11 Re: AI agent debug代码的一个完整案例

帖子 forecasting »

你开发得怎么样了?
回复

回到 “葵花宝典(Programming)”