AI Agents and Coding Assistants
Licensing Questions Raised by AI-Generated Source Code
Who owns AI-written code, whether it can carry someone else's license duties and what teams can do while the law develops.
Key takeaways
- Source code is generally protected by copyright, and a license sets the terms on which others may use it.
- Purely machine-generated material may receive no copyright protection in some places, including under the U.S. human authorship rule.
- A tool can occasionally reproduce recognizable existing code, whose license conditions may then matter to you.
- Read the tool's terms, keep records, check suspicious output and follow your employer's and project's policies.
AI-generated code raises a few separate licensing questions: whether anyone holds copyright in it, whether it might copy someone else's protected code and bring that code's conditions along, whether training on public code was lawful and what your tool's terms and your own contracts require. Some of these remain unsettled, and answers can differ between countries.
You can still manage the risk sensibly. This article explains the questions in general terms. It is not legal advice, and a project with real money or obligations behind it deserves a lawyer who knows the relevant jurisdiction.
How code licenses work
Copyright usually arises automatically when a person writes code. Publishing it where others can read it does not hand over the right to reuse it. A license grants that permission, often with conditions. Code posted with no license at all should be treated as not free to reuse.
| License family | Common examples | Typical conditions when you share |
|---|---|---|
| Permissive | MIT, BSD, Apache 2.0 | Keep copyright and license notices; Apache adds other terms, including on patents |
| Weaker copyleft | LGPL, Mozilla Public License | Share changes to the covered parts under the same terms |
| Strong copyleft | GPL | Distributed combined works generally must offer source under the GPL |
| Network copyleft | AGPL | Source duties can also apply when users interact with a modified version over a network |
| Proprietary | Commercial agreements | Only what the contract allows |
This is a simplified summary. The license text controls, and how the conditions apply to a particular combination of code can be a hard question.
Who owns generated code?
In the United States, copyright requires human authorship. The Copyright Office has taken the position that material produced by a machine without enough human creative control is not protected, while human contributions such as writing, selecting, arranging or substantially modifying can be. Where the line falls depends on the facts. Other countries take their own approaches, and some have different provisions for computer-generated works. See the human authorship rule.
Consider what this means in practice. If parts of your program cannot be protected, you may have difficulty stopping someone who copies those parts. Your license on them may carry less force. A typical project mixes human design and editing with generated passages, which makes the boundary harder to draw.
Ownership is also a contract matter. Many providers' terms say that, as between you and the provider, the user keeps or receives rights in the output. Such a clause cannot create copyright that the law does not grant, and it cannot give you rights belonging to a third party.
Can output copy someone else's code?
Models learn patterns from large collections of code. Most suggestions are ordinary: a loop, a standard way to open a file. Short, functional and conventional fragments often receive little or no protection, since there are few sensible ways to write them.
Occasionally a model can reproduce a longer, distinctive passage close to its source, particularly when prompted with the opening of a well-known function or with an unusual comment. If that source carries conditions, using the passage without meeting them may infringe, and not knowing where it came from does not necessarily protect you.
Warning signs include a copyright line or author name in the output, unusual comments that refer to things outside your project, a sizable specialized algorithm appearing complete and a style sharply unlike the surrounding code. Some tools offer a filter that blocks or flags matches with public code. Turn it on if you can, and remember that a filter may miss altered copies.
Was training on public code lawful?
This is a separate question about what the developer of the model did. Those who object argue that code was shared under conditions, such as attribution, that are lost when it feeds a commercial product. Those who defend training argue that learning general patterns is a different use from copying a work, and that in the U.S. it can qualify as fair use, a flexible defense weighed case by case. Other places rely on specific exceptions for text and data mining, with their own limits.
Lawsuits have raised these points, including a prominent U.S. case about a coding assistant. Court rulings tend to be narrow, may be appealed and may not apply to other facts. The arguments are set out in fair use and AI training. Check a current, reliable source before relying on the state of any case.
Three hypothetical situations
A common helper. You ask for a function that removes extra spaces from a sentence and receive three conventional lines. There are very few reasonable ways to write it, and nothing marks it as anyone's distinctive work. Most teams would treat this as ordinary, reviewing it for correctness like anything else.
A suspiciously complete algorithm. You ask for an image compression routine and receive two hundred polished lines, with comments mentioning a file your project does not have. That is a reason to pause. Search for distinctive lines or comments. If you find a matching source, read its license and either meet the conditions or replace the code. If you find nothing, you still have no proof of origin, and a maintained library with a clear license is often the safer choice.
A client delivery. You build software under a contract saying that you will transfer all rights in the work. Large parts were generated. You may be unable to transfer copyright that never arose, and the client may care. Raising the matter before signing, and agreeing wording that reflects how the work is made, is far easier than disputing it afterward.
In each case the sensible effort depends on how distinctive the code is, how widely it will be distributed and how much would be lost if a problem surfaced. A school exercise and a product shipped inside thousands of devices do not call for the same process.
Questions to settle before shipping
Read the terms and the contracts
Terms can differ between a free consumer version and a business plan from the same company. Look for these points.
- What rights you receive in the output, and any limits on using it.
- Whether your prompts and code are stored or used for training.
- Whether the provider offers an indemnity, a promise to defend or compensate you against certain claims, and the conditions attached, such as keeping filters on.
- Acceptable-use restrictions.
Then look at your own obligations. An employment agreement or client contract may require that you own or can transfer everything you deliver, or that you warrant it is original. Generated material can complicate both promises, so raise it openly. Pasting a client's confidential code into an unapproved service may breach a duty regardless of any copyright issue; see reading data terms.
Open-source projects and contributions
Open-source projects have taken varied stances. Some accept AI-assisted contributions with disclosure, some restrict or refuse them and many are still deciding. Many ask contributors to certify that they have the right to submit what they send, for example through a Developer Certificate of Origin or a contributor agreement. If you cannot tell where a passage came from, think hard before making that certification.
Read the contribution guide, say how you used a tool where asked and make sure you understand every line. Maintainers carry the long-term burden of unclear code.
Reduce the risk in daily work
Keep generated pieces small and shape them yourself. Ask for explanations and write your own version of important parts. Prefer well-licensed libraries to pasted blocks of unknown origin, and keep an inventory of third-party components. Run license and code-matching scanners if your organization has them.
Treat added packages as part of the same question, and confirm they are real, as discussed in invented package names. Build license checks into code review, and keep commit history that shows what people changed.
Common questions
If the assistant says the code is free to use, can I rely on that?
No. A model usually cannot trace where a passage came from, and its statement grants no rights. Rely on documented sources and actual license texts.
Does rewriting a suggestion remove the problem?
Superficial changes such as renaming variables may leave a copy that still infringes. Writing your own solution from an understanding of the problem is a stronger position.
I only use the code privately. Does any of this matter?
Many open-source conditions are triggered by sharing or offering the software to others, so private use raises fewer of them. Proprietary restrictions, confidentiality duties and tool terms can still apply, and private projects have a habit of becoming public ones.